Php Regex: isolate and count occurences -


so far managed isolate , count pictures in string doing this:

preg_match_all('#<img([^<]+)>#', $string, $temp_img);  $count=count($temp_img[1]); 

i similar parts this:

"code=myrand0mc0de123".

for instance, let's have string:

$string="my first code code=azerty , second 1 code=qsdf1e" 

i store "azerty" , "qsdf1e" in array.

i tried bunch of regex isolate "code=..." none has worked me. obviously, regex beyond me.

thank you.

are looking this?

preg_match_all('#code=([a-za-z0-9]+)#', $string, $results); $count = count($results[1]); 

Comments