Search txt file not finding full word
i am trying to run a simple search within a PHP script, i am not able to
work out what is going wrong. i am searching for the word 'James' within
the txt file, i know that it is in there however i am getting no results.
if i however replace "/James/" with "/J/" i get the results that i should.
i will past the content of the txt file below the code
<?php
$lines = file('ServicesResults.txt');
$lines_two = preg_grep("/James/", $lines);
foreach($lines_two as $name){
echo "$name<br>";
}
?>
------txt file content----- Breanna says hello Joe says hello Steven says
hello Lyn says hello Len says hello James says hello
-----Results of search "/J/" ----- Joe says hello James says hello
----No results of search "/James/"---- ----No results of search "/Ja/"----
i am sorry, this seems like a really stupid question, i just can't work
out what i am doing wrong
Thanks all James
No comments:
Post a Comment