4wt667KNXI
3J8fnObHjG
XZKB9rnvZU
Rx1VJu8sx5
MiAo8FaCOx
JB2RC2oFnq
上面六组字符串,是随机变化的,现在我想获取这六组字符串的第一个数字,如上面的六组我想最后得到:439182,请问应该怎么写代码?
$s = <<<TXT4wt667KNXI3J8fnObHjGXZKB9rnvZURx1VJu8sx5MiAo8FaCOxJB2RC2oFnqTXT;$arr = preg_split('/[\s]+/s', $s);$str = '';foreach($arr as $v){ preg_match('/\d/', $v, $m); $str .= $m[0];}echo $str;
$s =<<< TXT4wt667KNXI3J8fnObHjGXZKB9rnvZURx1VJu8sx5MiAo8FaCOxJB2RC2oFnqTXT;preg_match_all('/(\d+?).*$/m', $s, $m);echo join('', $m[1]);