I am struggling with PHP a bit.
I created an array and filled a few positions with some curl return data.
I dont see how I would search each array position for <p><strong>
and return every character from that to </p>
.
From a terminal I might do something like this:
grep -A 2 strong | sed -e 's/<p><strong>//' -e 's/<\/strong><br\/>//' -e 's/<br \/>//' -e 's/<\/p>//' -e 's/--//' -e 's/^[ \t]*//;s/[ \t]*$//'
but I am lost doing this in PHP
any advice?
Edit: I want the contents of every <p><strong>
to the </p>
Edit 2: Here is the code I am trying:
$m=array();
preg_match_all('/<p><strong>(.*?)<\/p>/',$buffer,$m);
$sizeM = count($m);
for ( $counter2 = 0; $counter2 <= $sizeM; $counter2++)
{
$displayString.= $m[$counter2];
}
And getting ArrayArrayArray...as my $displayString
Edit 3: I am doing this:
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL, $url);
curl_setopt($curl_handle, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110303 Ubuntu/10.04 (lucid) Firefox/3.6.15");
curl_setopt($curl_handle, CURLOPT_HEADER, 0);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
$m=array();
preg_match_all('/<p>.*?<strong>(.*?)<\/p>/i',$buffer,$m);
foreach($m[1] as $mnum=>$match) {
$displayString.='Match '.$mnum.' is: '.$match."\n";
}
` element which starts with a `` element?
– vbence Mar 24 '11 at 16:53