Php 使用preg_replace功能时出现问题

Php 使用preg_replace功能时出现问题,php,preg-replace,Php,Preg Replace,当我使用这个原生php函数时,有一个问题:preg_replace。 有人经历过这种情况吗? 当我运行此简单脚本时: echo preg_replace('/amount_number/i','$100',"this is amount: amount_number"); 它只输出: this is amount: 0 审理了另一案件: echo preg_replace('/amount_number/i','$11100',"this is amount: amount_number"

当我使用这个原生php函数时,有一个问题:preg_replace。 有人经历过这种情况吗? 当我运行此简单脚本时:

echo preg_replace('/amount_number/i','$100',"this is amount: amount_number"); 
它只输出:

this is amount: 0
审理了另一案件:

echo preg_replace('/amount_number/i','$11100',"this is amount: amount_number"); 
输出:

this is amount: 100

似乎输出字符串被截断为“$”号和接下来的2个字母。

问题是使用
$10
从正则表达式中获取捕获组(第十个)。所以,你必须用
\
来逃避这个问题,就像这样()

输出:

this is amount: $100
this is amount: $100