-1 什麼是抽取以下字符串數量的最佳方式:使用PHP裏面找數{{2461245}} "This is a test string {2461245} and I need to extract the number" 謝謝。 來源 2016-01-23 NestMan +0 請參閱http://stackoverflow.com/questions/6278296/extract-numbers-from-a-string – PrinceG
1 這會幫助你: $myText = 'This is a test string {2461245} and I need to extract the number'; preg_replace("/[^0-9]/","",$myText); 你所說的有:我要取代一切是不是會將myText變量數由「」,這意味着一切都將留在最後是你的號碼。 來源 2016-01-23 02:03:10 Isuka +0 祝福你Isuka。 – NestMan +0 其實我意識到這不適用於所有情況,因爲正在掃描的字符串有時可能包含其他數字。而我真正需要的是找到現在放在HTML註釋中的數字,如下所示:<! - 2461245 - >。謝謝。 – NestMan
請參閱http://stackoverflow.com/questions/6278296/extract-numbers-from-a-string – PrinceG