使用PHP查找{{2461245}内的数字

使用PHP查找{{2461245}内的数字,php,Php,提取以下字符串中的数字的最佳方法是什么: "This is a test string {2461245} and I need to extract the number" 谢谢。这将有助于您: $myText = 'This is a test string {2461245} and I need to extract the number'; preg_replace("/[^0-9]/","",$myText); 您的意思是:我想用“”替换myText变量中不是数字的所有内容,这意

提取以下字符串中的数字的最佳方法是什么:

"This is a test string {2461245} and I need to extract the number"
谢谢。

这将有助于您:

$myText = 'This is a test string {2461245} and I need to extract the number';
preg_replace("/[^0-9]/","",$myText);

您的意思是:我想用“”替换myText变量中不是数字的所有内容,这意味着最后保留的所有内容都是您的数字。

请看,实际上我意识到这并不适用于所有情况,因为正在扫描的字符串有时可能包括其他数字。我真正需要的是找到我现在放在HTML注释中的数字,比如:。非常感谢。