I want to get the value inside a span id or div id. For example from
<span id开发者_如何学运维="lastPrice">29.00</span>
i want to get the 29.00. please help.
If you want to do this through regexp
that badly.
$string = "<span id=\"lastPrice\">29.00</span>";
preg_match("/\<span id\=\"lastPrice\"\>([\d.]+?)\<\/span\>/",$string,$match);
print "<pre>"; var_dump($match[1]); print "</pre>";
But there are far more better ways.
Take a look at XPath => PHP - Searching and filtering with XPath
[...] XPath is a darn sight easier than regular expressions for basic usage. That said, it might take a little while to get your head around all the possibilities it opens up to you!
Google will give u plenty of examples and tutorials.
精彩评论