Home  >  Article  >  Backend Development  >  匹配到这个数组所有成员的正则

匹配到这个数组所有成员的正则

WBOY
WBOYOriginal
2016-06-13 11:51:23868browse

求一个匹配到这个数组所有成员的正则
array(100-10, -50,200-20, 300-30, -30)求一个匹配到这个数组所有成员的正则
------解决方案--------------------

$arr = array('100-10', '-50','200-20', '300-30', '-30');<br />	$b = array();<br />	foreach ($arr as $value) {<br />		if(preg_match("/[\d-]+/", $value,$match)){<br />			array_push($b, $match);<br />		}<br />	}<br />	var_dump($b);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn