regex - Php Preg Match, how can i do this -
<td class=bilgi_satir width="45%"><b>( place want fetch ) </b></td> ( other html tags ) <td class=bilgi_satir width="25%"><b>( place want fetch ) </b></td> ( other html tags ) <td class=bilgi_satir width="35%"><b>( place want fetch ) </b></td> ( other html tags )
how can fetch them array ?
width variable changing ...
try solve html problem regular expression, , have 2 problems. if want dirty regular expression, can done. shouldn't rely on it. simplest regex like:
preg_match_all( "/<td class=bilgi_satir width=\"..%\"><b>(.*)<\/b>/i", $your_html_here, $m );
this returns want print_r( $m[1] );
(i added 1, 2, 3 tell 'em apart)
array ( [0] => ( place want fetch 1 ) [1] => ( place want fetch 2 ) [2] => ( place want fetch 3 ) )
best way dom parsing. example:
$doc = new domdocument(); $doc->loadhtml( $your_html_here ); $x = new domxpath( $doc ); $results = $x->query("//td[@class='bilgi_satir']//b"); # $results->length shows 3 $ret = array(); foreach( $results $count => $result ) { printf( "item # %s = %s\n", $count, $result->nodevalue ); # debug $ret[] = $result->nodevalue; }
this display:
item # 0 = ( place want fetch 1) item # 1 = ( place want fetch 2) item # 2 = ( place want fetch 3)
edit: dumping node value array lets access via array, wanted.
Comments
Post a Comment