Is there a way to find array values based on matching word?
Posted: Fri Apr 17, 2009 4:32 am
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.
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.