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

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

WBOY
Release: 2016-06-13 11:51:23
Original
909 people have browsed it

求一个匹配到这个数组所有成员的正则
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);
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template