PHP 数组转换

$a=Array([0]=>Array([day]=>/[tojiurl]=>20)[1]=>Array([day]=>/effect/1-7.html[tojiurl]... $a=Array (
[0] => Array ( [day] => / [tojiurl] => 20 )
[1] => Array ( [day] => /effect/1-7.html [tojiurl] => 3 )
[2] => Array ( [day] => /praise.html [tojiurl] => 2 )
[3] => Array ( [day] => /effect/1-4.html [tojiurl] => 2 )
[4] => Array ( [day] => /effect/1-6.html [tojiurl] => 2 )

[5] => Array ( [name] => Sogou web [tojiname] => 13 )
[6] => Array ( [name] => Google [tojiname] => 11 )
[7] => Array ( [name] => 百度PC蜘蛛 [tojiname] => 10 )
[8] => Array ( [name] => 360PC蜘蛛 [tojiname] => 1 )
[9] => Array ( [name] => 360移动蜘蛛 [tojiname] => 1 )

[10] => Array ( [url] => / [zhuantai] => 404 [ztid] => 1 )

[11] => Array ( [dateline] => 1554432969 [so] => Sogou web [sjid] => 1 )
[12] => Array ( [dateline] => 1554530873 [so] => Sogou web [sjid] => 1 )
[13] => Array ( [dateline] => 1554410795 [so] => Sogou web [sjid] => 1 )
[14] => Array ( [dateline] => 1554462555 [so] => 百度PC蜘蛛 [sjid] => 1 )
[15] => Array ( [dateline] => 1554369525 [so] => Sogou web [sjid] => 1 )
)
转换成下面这种数组
$b=Array (
[0] => Array ( [day] => / [tojiurl] => 20 [name] => Sogou web [tojiname] => 13 [url] => / [zhuantai] => 404 [ztid] => 1 [dateline] => 1554432969 [so] => Sogou web [sjid] => 1)
[1] => Array ( [day] => /effect/1-7.html [tojiurl] => 3 [name] => Google [tojiname] => 11 [url] => [zhuantai] => [dateline] => 1554530873 [so] => Sogou web [sjid] => 1)
[2] => Array ( [day] => /praise.html [tojiurl] => 2 [name] => 百度PC蜘蛛 [tojiname] => 10 [url] => [zhuantai] => [dateline] => 1554410795 [so] => Sogou web [sjid] => 1)
[3] => Array ( [day] => /effect/1-4.html [tojiurl] => 2 [name] => 360PC蜘蛛 [tojiname] => 1 [url] => [zhuantai] => [dateline] => [dateline] => 1554462555 [so] => 百度PC蜘蛛 [sjid] => 1)
[4] => Array ( [day] => /effect/1-6.html [tojiurl] => 2 [name] => 360移动蜘蛛 [tojiname] => 1 [url] => [zhuantai] => [dateline] => 1554369525 [so] => Sogou web [sjid] => 1)
)
展开
 我来答
司马刀剑
高粉答主

2019-04-10 · 每个回答都超有意思的
知道顶级答主
回答量:4.6万
采纳率:93%
帮助的人:7537万
展开全部

使用PHP implode 函数:将数组元素组合为字符串。实现代码如下:

PHP implode 函数的作用解析如下:

1、PHP implode()作用:

implode() 函数用于将数组元素组合为一个字符串,并返回该字符串。

2、语法:

string implode( string glue, array array )。

3、参数说明:

4、连接符为 ^ 的例子:

5、浏览器输出:

6、可以使用空格作为连接符:

7、此时的输出为:

本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式