preg_matchall
$regex = "/[a-zA-Z]+ (\d+)/"; $input\_str = "June 24, August 13, and December 30"; if (preg\_match\_all($regex, $input\_str, $matches\_out)) { // Output: 2 echo count($matches\_out); // Output: 3 echo count($matches\_out[0]); // Output: Array("June 24", "August 13", "December 30") print\_r($matches\_out[0]); // Output: Array("24", "13", "30") print\_r($matches\_out[1]); }
Comments