Home > php教程 > php手册 > PHP Warning: implode() [function.implode]: Invalid

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

WBOY
Release: 2016-05-23 13:07:28
Original
1817 people have browsed it

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

我的程序,代码如下:

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

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

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

参数描述

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

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

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

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

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


教程地址:

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template