在 PHP 中使用 preg_Replace() 函数时出现问题

Issue while using the preg_Replace() function in PHP

我在CorePHP中使用了preg_Replace函数如下:

$d [] = preg_Replace("^0", "", $a);

但我收到以下错误:

Warning: preg_replace(): No ending delimiter '^'

无结束分隔符 是什么意思?我在这里错过了什么?

您需要将语法稍微更改为以下两个选项之一:

$d[] = preg_replace("/^0/", "", $a);

$d[] = preg_replace("(^0)", "", $a);

Demo