|
Posted by gosha bine on 05/31/07 16:41
On 31.05.2007 14:10 The.Relinator@gmail.com wrote:
> I'm just wondering what the best way is to extract and display a
> number from a html file.
>
> I tried the following piece of code, however it does not work.
>
> ereg('\d\.\d', $content, $reg);
> echo $reg[0];
>
Don't use ereg, it's deprecated.
preg_match_all('/-? ( \d+\.?\d* | \.\d+) /x', $html, $matches);
finds numbers like "12", "-123.456" and ".789" and places them in array
$matches.
--
gosha bine
extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
Navigation:
[Reply to this message]
|