开发者

help with php regexp

I have table like this -> http://jsfiddle.net/jurisKaste/FvgeQ/

And I need to get array of all those numbers from id column... im using php code and I have so far this piece of code from here. i must use php only! Get number from a string

how could i modify t开发者_运维问答his regexp to get a bit readable array ? so the complete code look like this


    $data = str_replace(",", ".", $data); // $data is that html code from fiddle!
    preg_match_all("/[+-]?\d+[\d\.Ee+]*/", $data, $matches);
    var_dump($matches);

edit: what about this ?


    $data = str_replace(",", "", $data);
    preg_match_all("/[0-9]{5,6}/",$data,$matches);
    print var_dump($matches);

it works for me...


Try this, it looks for the first td after each <tr then gets the number in between the <td> and </td>

preg_match_all("/\<tr.+?td.+?\>([\d,]+?)\</s",$string,$matches);
print "<pre>"; var_dump($matches); print "</pre>";


try it

$xml=new SimpleXMLElement($data);
foreach($xml->tr as $tr){
    echo $tr->td[0];
}


$data = str_replace(",", "", $data);
preg_match_all("/[0-9]{5,6}/",$data,$matches);
print var_dump($matches);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜