I have a string $str = "4sX3yY4mj2DT9gVOOS0x60onT08lwzLLZBqn8"
. Now I want to remove the first 5 numeric characters from the string.
我有一个字符串$ str =“4sX3yY4mj2DT9gVOOS0x60onT08lwzLLZBqn8”。现在我想从字符串中删除前5个数字字符。
How do I do that in php?
我怎么在PHP中这样做?
1 个解决方案
#1
9
Use the limit parameter with preg_replace:
在preg_replace中使用limit参数:
$str = preg_replace('~\d~', '', $str, 5);
#1
9
Use the limit parameter with preg_replace:
在preg_replace中使用limit参数:
$str = preg_replace('~\d~', '', $str, 5);