Jump to content

preg_match_all to array help.


QuietRiot

Recommended Posts

 

I've been struggling with this for awhile now. How do I get the contents of the array to actually display. I keep getting "Array".

 

 if ( preg_match_all("#<td class=\"alt1\"><div class=#i", $html, $matches) ) {
            	$res = array();
    		array_push($res,$matches[0]);
    		array_push($res,count($matches[0]));
                echo $res[0];  

    }

Link to comment
https://forums.phpfreaks.com/topic/197793-preg_match_all-to-array-help/
Share on other sites

thank you. If I wanted to do a preg_match_all against those results how would I go about doing that? I want to get the actual names now and they are between <b>name1</b>:

 

if ( preg_match_all("/<td class=\"alt1\"><div class=\"smallfont\"*>(.*)<\/td>/Ui", $html, $matches) ) {
       	$res = array();
    		array_push($res,$matches[0]);
    		array_push($res,count($matches[0]));
	print_r($res[0]); 

	preg_match_all("/<b*>(.*)<\/b>/Ui", $res[0], $bolds);
	$names = array();
    		array_push($names,$bolds[0]);
    		array_push($names,count($bolds[0]));
	print_r($names[0]);
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.