我需要在php
字符串中第一次出現數字後刪除所有內容,但要保留數字。我無法保留該號碼:當我寫這個在第一次出現數字後刪除所有內容php
preg_replace('/[0-9].*/', '', $string);
它刪除包括數字在內的所有信息。我的另一個問題是字符串是希伯來語我試圖使用這個功能:
$count = mb_strlen($string,'UTF-8');
$i = 0;
while($i < $count) {
if(ctype_digit($string[$i])) {
echo "First digit found at position $i.";
return;
}
$i++;
}
但它也行不通。任何幫助?
中有什麼'$ string'? –
這是一個帶數字的希伯來字符串。 –