2011-07-31 18 views

回答

1
php> echo preg_replace("/\w+/", '+\0*', "Car Bar") 
+Car* +Bar* 
+1

这不是我不喜欢给出答案,而是给出一个现成的代码示例并不是教导其他人的最佳实践...... – Griwes

+0

@Dogbert:这是否包括与两个或多个空格分开的单词? – einstein

+0

@ Woho87,是的。 – Pindatjuh

1

无论explode()字符串中的前插和追加的部分字符串的符号,后来implode(),或使用正则表达式。

0
$string = preg_replace("/\w+/", "+$0*", $string);