Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我似乎无法做到这一点!
我正在尝试用相同数量的其他字符替换相同数量的空格:
$s="abc def f"; echo preg_replace('/[\s*]+/', 'X', $s);
你需要正则表达式吗?
$s = 'abc def f'; echo str_replace(' ', 'X', $s); // output: abcXXdefXf
只需使用str_replace.
str_replace
str_replace(" ", "X", $s);
$s="abc def f"; echo preg_replace('/\s/', 'X', $s);