Hi guys,
I have this situation:
First the text file is splitted into string values starting and ending with $word1 and $word2.
How can I find all the array values which are holding specific word in the string value?
$pattern = '/'.$word1.'(.*?)'.$word2.'/imsx';
preg_match_all($pattern,file_get_contents($file), $matches);
echo "<pre>".print_r($matches,true).'</pre>';
well,this outputs an array like:
Array
(
[0] => Array
(
[0] => first string block like
[1] => second
[2] => third
)
[1] => Array
(
[0] => first string block like
[1] => second
[2] => third
probably I'm missing something here ... I've tried almost everything.
Is there a way to find array values based on matching word?
Moderator: General Moderators
Is there a way to find array values based on matching word?
Last edited by 100faces on Fri Apr 17, 2009 5:06 am, edited 1 time in total.
Re: Is there a way to find array values based on matching word?
Which "string value"?100faces wrote:How can I find all the array values which are holding specific word in the string value?
Re: Is there a way to find array values based on matching word?
every array value is a string like " word1 word2 word3 wordN"
my goal is to find all these values which have "word3" in the string and to ouput the value to new array.
my goal is to find all these values which have "word3" in the string and to ouput the value to new array.