将键数组附加到数组值
array
'strongfruit' =>
array
apple => string 'say:helloworld'
banana => string 'say:omgdude'
grape => string 'say:dope'
alienfruit => string 'say:ganja'
'weakfruit' =>
array
apple => string 'say:helloworld'
banana => string 'say:omgdude'
grape => string 'say:dope'
orange => string 'say:yeahdude'
'moreweakerfruit' =>
array
apple => string 'say:helloworld'
anotheralienfruit => string 'say:yeahhellyeah'
(etc)
就像
array
apple => string 'strongfruit:say:helloworld' ( from strong )
banana => string 'strongfruit:say:omgdude' ( from strong )
grape => string 'strongfruit:say:dope' ( from strong )
alienfruit => string 'strongfruit:say:ganja' ( from strong )
orange => string 'weakfruit:say:yeahdude' ( from weak)
anotheralienfruit => string 'moreweakerfruit:say:yeahhellyeah' ( from weakeretc)
昨天一样,我询问连接数组,保留不同的值,如果相同则选择一个。使用 php
这是我们如何加入它们来获取订单;
$result = array();
foreach ($array as $value) { $result += $value; }
不同的是我们如何将键附加到数组中的值?。
array
'strongfruit' =>
array
apple => string 'say:helloworld'
banana => string 'say:omgdude'
grape => string 'say:dope'
alienfruit => string 'say:ganja'
'weakfruit' =>
array
apple => string 'say:helloworld'
banana => string 'say:omgdude'
grape => string 'say:dope'
orange => string 'say:yeahdude'
'moreweakerfruit' =>
array
apple => string 'say:helloworld'
anotheralienfruit => string 'say:yeahhellyeah'
(etc)
to be something like
array
apple => string 'strongfruit:say:helloworld' ( from strong )
banana => string 'strongfruit:say:omgdude' ( from strong )
grape => string 'strongfruit:say:dope' ( from strong )
alienfruit => string 'strongfruit:say:ganja' ( from strong )
orange => string 'weakfruit:say:yeahdude' ( from weak)
anotheralienfruit => string 'moreweakerfruit:say:yeahhellyeah' ( from weakeretc)
yesterday i ask about joining arrays, preserving different value, pick one if same. with php
heres how we join them to get the order;
$result = array();
foreach ($array as $value) { $result += $value; }
the different is how can we append the key to a value in an array?.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)