PHP regex match data between html -
PHP regex match data between html -
i have created regex, extracts info need, includes ">" character, how rid of it? here's code.
<?php $content = file_get_contents('www.example.com'); $pattern = "/>([0-9]{2}\.[0-9]{3})/"; preg_match_all($pattern, $content, $matches); echo $matches[0][2]; ?> and html extract
<td style="text-align:right" class="row">23.020</td> it gives me "<23.020" need "23.020" know it's n00b question, how rid of "<"
$content = '<td style="text-align:right" class="row">23.020</td>'; $pattern = "/>([0-9]{2}\.[0-9]{3})/"; preg_match_all($pattern, $content, $matches); var_dump($matches);
will give you
array(2) { [0]=> array(1) { [0]=> string(7) ">23.020" } [1]=> array(1) { [0]=> string(6) "23.020" } } so utilize $matches[1][0].
php regex preg-match-all
Comments
Post a Comment