例如$str = '-1- -2- -3- -4- -5-';
我想取 第三个 -\d- 的结果能怎写呢?我这么写貌似不行$str = '-1- -2- -3- -4- -5-';
preg_match("/(?<val>(-\d+-){3})/i",$str,$b);
print_r($b);
我想取 第三个 -\d- 的结果能怎写呢?我这么写貌似不行$str = '-1- -2- -3- -4- -5-';
preg_match("/(?<val>(-\d+-){3})/i",$str,$b);
print_r($b);
$str = '-1- -2- -3- -4- -5-';
preg_match_all("/-\d+-/",$str,$b);
print_r($b[0][2]);
?>
<?php $str = '-1- -2- -3- -4- -5-';
preg_match_all('/(?:^(?:-\d-\s*?){2})(?:.*?)(-\d-)/' , $str , $ary);
echo '<pre>'; var_dump($ary); echo '</pre>'; echo $ary[1][0];?>我这个比楼上的几个都要快。
$str = '-1- -2- -3- -4- -5-';
$arrStr = explode(" ",$str);
echo $arrStr[2];