我已經嘗試了一切,但答案可能非常簡單。變量$data['phone']
是例如954a23589
,我只想讓數字生病讓他們。獲取數組而不是字符串
$phoneW = strval($data['phone']);
preg_match_all('!\d+!', $phoneW, $matches);
print_r(array_values($matches)); echo '<br /><br />';
輸出是
Array ([0] => Array ([0] => 954 [1] => 23589))
我希望他們的大家在一起字符串或INT(無所謂)。
print_r(implode('',array_values($ matches))); – Kuro