Mega Code Archive

 
Categories / Php / Strings
 

Grouping captured subpatterns

<?php $todo = " first=a next=B last=C "; preg_match_all("/([a-zA-Z]+)=(.*)/", $todo, $matches, PREG_SET_ORDER); foreach ($matches as $match) {     print "The {$match[1]} action is {$match[2]} \n"; } ?>