php问题 如果将下面这段字符串转变为二维数组
{"0":{"url":"http:\/\/localhost\/Linux-dome\/phpcms01\/wangbingbing\/uploadfile\/2017...
{"0":{"url":"http:\/\/localhost\/Linux-dome\/phpcms01\/wangbingbing\/uploadfile\/2017\/1019\/20171019105819826.jpg","alt":"306414"},
"1":{"url":"http:\/\/localhost\/Linux-dome\/phpcms01\/wangbingbing\/uploadfile\/2017\/1019\/20171019105819731.jpg","alt":"306675"},
"2":{"url":"http:\/\/localhost\/Linux-dome\/phpcms01\/wangbingbing\/uploadfile\/2017\/1019\/20171019105820744.jpg","alt":"306681"},
"3":{"url":"http:\/\/localhost\/Linux-dome\/phpcms01\/wangbingbing\/uploadfile\/2017\/1019\/20171019105822824.jpg","alt":"306682"},
"4":{"url":"http:\/\/localhost\/Linux-dome\/phpcms01\/wangbingbing\/uploadfile\/2017\/1019\/20171019105823103.jpg","alt":"306704"}}
如何将上面这段字符串转变为二维数组 展开
"1":{"url":"http:\/\/localhost\/Linux-dome\/phpcms01\/wangbingbing\/uploadfile\/2017\/1019\/20171019105819731.jpg","alt":"306675"},
"2":{"url":"http:\/\/localhost\/Linux-dome\/phpcms01\/wangbingbing\/uploadfile\/2017\/1019\/20171019105820744.jpg","alt":"306681"},
"3":{"url":"http:\/\/localhost\/Linux-dome\/phpcms01\/wangbingbing\/uploadfile\/2017\/1019\/20171019105822824.jpg","alt":"306682"},
"4":{"url":"http:\/\/localhost\/Linux-dome\/phpcms01\/wangbingbing\/uploadfile\/2017\/1019\/20171019105823103.jpg","alt":"306704"}}
如何将上面这段字符串转变为二维数组 展开
3个回答
展开全部
/*二维数组转换为字符串其实很简单,用一个for循环就OK了
你读取的二维数组$arr,比如是Array ( [0] => Array ( [name] => 行业 ) [1] => Array ( [name] => 论坛 ) )
代码开始*/
$sum = 0;
$count = count($arr);
for($i = 0; $i < $count; $i++){
$sum .= $arr[$i]['name'];
}
$sum = substr($sum,1);
echo($sum);
//输出 “行业论坛”
你读取的二维数组$arr,比如是Array ( [0] => Array ( [name] => 行业 ) [1] => Array ( [name] => 论坛 ) )
代码开始*/
$sum = 0;
$count = count($arr);
for($i = 0; $i < $count; $i++){
$sum .= $arr[$i]['name'];
}
$sum = substr($sum,1);
echo($sum);
//输出 “行业论坛”
更多追问追答
追问
我是想将上面我写的那段字符串转变为二维数组
追答
额
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
6、 江南春 杜牧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2017-10-20
展开全部
d数据库还未能导出
追问
这段字符串是从数据库里面获取到的 想进行遍历 只能把它先转为二维数组 然后再遍历 不知道怎么转为二维数组
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询