我必須測試字符串是以還是以+開頭。Preg_match如果字符串以「00」{數字}或「+」{number}開頭
僞代碼:
Say I have the string **0090** or **+41**
if the string begins with **0090** return true,
elseif string begins with **+90** replace the **+** with **00**
else return false
的最後兩個數字可以是0-9。
我該如何做到這一點在PHP?
選擇我的答案@streetparade謝謝,但看看由codaddict答案。 – 2010-03-29 09:17:23
if(preg_match(「!^(?: 00 | \ +)(?:\ d \ d)!」,$ input)> 0){}請參閱codaddict的[answer](#2536697)。 – 2010-03-29 08:43:30