php - Preg_match symbols using? -


in code

<div class="count">#3</div><div class="count">#4</div><div class="count">#5</div> 

the numbers different every time how can see them , sum tested with

$b = explode('</div><div class="count">', $cnt); for($i=1;$i<sizeof($b);$i++)     preg_match("/([0-9]+)/", $b[$i], $m); 

but see numbers not sum :(

you don't need regular expressions even:

echo array_sum(str_split(filter_var($string, filter_sanitize_number_int))); 

outputs

12 

Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -