0

I am stuck in a very simple PHP problem. I am having a string as $a = "123 text"; or it can also be $a="lorem ipsum 1234 dummy text";

I want that the output shall be $a="text"; or $a="lorem ipsum dummy text"; In short I want to exclude the number that can either be 123 or 12345 or anything else.

I have tried $except_txt = "text 123456 dummy"; $pattern = "/12/"; $replacement = ""; $path = preg_replace($pattern, $replacement, $except_txt);

but I get output as $except_txt = "text 3456 dummy";

4

2 回答 2

2

此代码段解决了您的问题:

$a = "lorem ipsum 1234 dummy text";
$a = preg_replace("/[\d]/", "", $a);
echo $a;
于 2013-11-05T12:00:59.387 回答
0

尝试:

preg_replace("/(\d)+/", "", $except_txt);
于 2013-11-05T10:39:45.093 回答