[英]str_replace “|” using php
I want to insert "|"
我想插入
"|"
in place of space " "
using str_replace
, but when I use it 使用
str_replace
代替空间" "
,但是当我使用它时
str_replace("|", " ", $word);
All space between the words were deleted. 单词之间的所有空格均被删除。 Any help?
有什么帮助吗?
-- The code - 编码
$word=explode(" ",$FromForm);
$word_count - str_word_count($_post['xxx'];
for($i=0;$i<=$word_count;$i++) {
echo str_replace("|"," ",$word[$i]);
//it echos fine without the string replace
}
您可以尝试str_replace(" "," | ",$word);
I think you got the function the wrong way, if you are trying to replace certain text with |
如果您想用
|
替换某些文本,我认为您使用了错误的方法|
, then you have to do something like this. ,那么您必须做这样的事情。
str_replace(" ","|",$word);
UPDATE UPDATE
Since you exploded $FromForm by " "
, there will be nothing to replace by str_replace later on. 既然你展开$ FromForm通过
" "
,会有什么用str_replace函数以后更换。
(I'm still having a hard time understanding what and why you are trying to do, but…) (我仍然很难理解您要做什么以及为什么要这么做,但是……)
Replace everything with: 将所有内容替换为:
$word = str_replace(" ", "|", $FromForm);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.