Evaluate a regular array (100-10,-50,200-20,300-30,-30) that matches all the members of this array to obtain a regular expression that matches all the members of this array.
Reply to discussion (solution)
$arr = array('100-10', '-50','200-20', '300-30', '-30');$b = array();foreach ($arr as $value) {if(preg_match("/[\d-]+/", $value,$match)){array_push($b, $match);}}var_dump($b);
$arr = array('100-10', '-50','200-20', '300-30', '-30');$b = array();foreach ($arr as $value) {if(preg_match("/[\d-]+/", $value,$match)){array_push($b, $match);}}var_dump($b);
Thank you, but it's not what I want.
This is what I need.
$ Arr = array ('1970-30', 'lsflsdf ', '50-10', '1970-30','-50 ', '1970-1000 ');
I need to assign different variables to the classes '2014-30' or '-30' and other classes separately.
What is the difference between-and?
$ Arr = array ('1970-10', 'lsflsdf ', '100-20','-50', '1970-20', '1970-30 ', '-30', '2014-1000'); $ a = array (); // store other types $ B = array (); // store foreach ($ arr as $ value) of the type '2014-30' or '-30' {if (preg_match ("/^ [\ d-] + /", $ value, $ match) {array_push ($ B, $ match);} else {array_push ($ a, $ value) ;}} var_dump ($ a, $ B ); // you can get two results for separating different types.