PHP 内爆功能不起作用
我有一个数组,我想通过 implode 函数将该数组转换为逗号分隔的字符串,但这不起作用。我的代码如下。
<?php
$relatedSlides = $result['RelatedSlideshows'];
$relatedSlides = implode(",",$relatedSlides);
echo $relatedSlides;
?>
$结果['相关幻灯片'];是一个数组,并且打印完美。这不是多维数组。这是简单的数组。我怎么做这个???
i have an array and i want to convert this array in comma seprated string by implode function but this is not working. my code is below.
<?php
$relatedSlides = $result['RelatedSlideshows'];
$relatedSlides = implode(",",$relatedSlides);
echo $relatedSlides;
?>
$result['RelatedSlideshows']; is an array and it is printing perfectly. this is not an multidimensional array. this is simple array. how i do this???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我猜这是 mysql_fetch_array() 或 mysql_fetch_assoc() 的结果。
如果您想从结果中内爆数组关联数组,请尝试 implode(",",$result);
但一定要使用 mysql_fetch_assoc(),因为 mysql_fetch_array() 返回 2 个合并数组,1 个关联数组和 1 个数字数组。
I guess that's a result from a mysql_fetch_array() or mysql_fetch_assoc().
If you want to implode the array associative array from the result, try implode(",",$result);
But be sure to use mysql_fetch_assoc(), because mysql_fetch_array() returns 2 merged arrays, 1 associative and 1 numeric.
simpleXML 对象不是数组。它是一个在某些情况下可以像数组一样对待的对象。 手册参考
SimpleXML 扩展提供了一个非常简单且易于使用的用于将 XML 转换为可以使用普通属性选择器和数组迭代器处理的对象的工具集。
尝试:
A simpleXML object is not an Array. It is an object that under some circumstances can be treated like an array. Manual Reference
The SimpleXML extension provides a very simple and easily usable toolset to convert XML to an object that can be processed with normal property selectors and array iterators.
Try:
给我:
希望里面有足够的隐含提示。
编辑:
尝试:
Gives me:
Hopefully there is enough implicit tips in there.
Edit:
try:
那么您的原始数组有问题,请检查此。
对 $result['RelatedSlideshows'] 进行 var 转储。
Something's wrong with your original array then, check this out.
Do a var dump of $result['RelatedSlideshows'].