Heim  >  Artikel  >  php教程  >  PHP Warning: implode() [function.implode]: Invalid

PHP Warning: implode() [function.implode]: Invalid

WBOY
WBOYOriginal
2016-05-23 13:07:281746Durchsuche

今天在做一个小的采集发布接口时发现使用implode函数老提示出错,但在网上找了一下解决不了,后来仔细看一原因是写法错误了,当然因这个问题也学了不少东西下面给各位整理了一些更合理使用implode()函数用法.

我的程序,代码如下:

echo $fileddata['house_feature']; 
if($fileddata['house_feature']){ 
    $fileddata['house_feature'] = implode('|||',$fileddata['house_feature']); 
}  
echo '----'.$fileddata['house_feature']

结果为:南北通透|||随时看房|||交通便利  --------

后来反复查没查出原因,百度搜索了一下有一个网友这样说implode(',',$goods_attr) 这个写的一点都不科学,应该做判断.if($goods_attr) 这一下想了,这个implode不是只能是把数组转换成字符吗?百度一下mplode() 函数把数组元素组合为一个字符串.

参数描述

separator可选,规定数组元素之间放置的内容,默认是 ""(空字符串).

array必需,要结合为字符串的数组.

后面没有值呀,后来代码如下:

$fileddata['house_feature'] = str_replace('|||',',',$fileddata['house_feature']);

再测试 南北通透|||随时看房|||交通便利南北通透,随时看房,交通便利 就是我想要的结果了.


教程地址:

欢迎转载!但请带上文章地址^^

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn