i need to extract all words that begin with "a" in file linux.words but i started to write code in php but i have problem i receive all words that contain "a" ,how to fix it, i want to use preg_match_all? <?php $counter=0; $content=file("linux.words"); foreach ($content as $line) { //$words = explode(' ', $line); // Split a line by the delimiter "spacer" preg_match_all("/[a-z]/i",$line,$result); } print_r($result)."<br>"; ?>
'~a[a-z]+~i' PHP: ... and print_r() after the loop, or add the results to an array and print it after it. (Also, replace + with * if you want the word "a" to count as well.)
Yes, but I won't. You've got all the pieces, now put them together. At least show me what you've tried.