您好我需要根据索引行
将此数组拆分为较小的新数组array(7) {
["device_name"]=>
array(10) {
[0]=>
string(13) "Beverly Hills"
[1]=>
string(13) "Beverly Hills"
[2]=>
string(13) "Beverly Hills"
[3]=>
string(13) "Beverly Hills"
[4]=>
string(13) "Beverly Hills"
[5]=>
string(13) "Beverly Hills"
[6]=>
string(13) "Beverly Hills"
[7]=>
string(13) "Beverly Hills"
[8]=>
string(13) "Beverly Hills"
[9]=>
string(13) "Beverly Hills"
}
["device_description"]=>
array(10) {
[0]=>
string(5) "Ajtjv"
[1]=>
string(5) "Gynfq"
[2]=>
string(5) "Gfkgl"
[3]=>
string(5) "Yadgv"
[4]=>
string(5) "Obvlf"
[5]=>
string(5) "Anmag"
[6]=>
string(5) "Zeypc"
[7]=>
string(5) "Rdeve"
[8]=>
string(5) "Iwxdd"
[9]=>
string(5) "Ciloy"
}
["device_url"]=>
array(10) {
[0]=>
string(22) "http://www.example.com"
[1]=>
string(22) "http://www.example.com"
[2]=>
string(22) "http://www.example.com"
[3]=>
string(22) "http://www.example.com"
[4]=>
string(22) "http://www.example.com"
[5]=>
string(22) "http://www.example.com"
[6]=>
string(22) "http://www.example.com"
[7]=>
string(22) "http://www.example.com"
[8]=>
string(22) "http://www.example.com"
[9]=>
string(22) "http://www.example.com"
}
["device_ip4"]=>
array(10) {
[0]=>
string(5) "Dnjon"
[1]=>
string(5) "Wnthd"
[2]=>
string(5) "Ybhmq"
[3]=>
string(5) "Dqojf"
[4]=>
string(5) "Pvdiv"
[5]=>
string(5) "Qobbu"
[6]=>
string(5) "Bvnic"
[7]=>
string(5) "Xezcs"
[8]=>
string(5) "Jliql"
[9]=>
string(5) "Lbbcv"
}
["device_ip6"]=>
array(10) {
[0]=>
string(5) "Haddj"
[1]=>
string(5) "Vodto"
[2]=>
string(5) "Roboi"
[3]=>
string(5) "Lyuvq"
[4]=>
string(5) "Zniny"
[5]=>
string(5) "Mmohr"
[6]=>
string(5) "Dwylp"
[7]=>
string(5) "Bneop"
[8]=>
string(5) "Aojdn"
[9]=>
string(5) "Dxtvy"
}
["device_username"]=>
array(10) {
[0]=>
string(26) "bhills_2852@mailinator.com"
[1]=>
string(26) "bhills_2852@mailinator.com"
[2]=>
string(26) "bhills_2852@mailinator.com"
[3]=>
string(26) "bhills_2852@mailinator.com"
[4]=>
string(26) "bhills_2852@mailinator.com"
[5]=>
string(26) "bhills_2852@mailinator.com"
[6]=>
string(26) "bhills_2852@mailinator.com"
[7]=>
string(26) "bhills_2852@mailinator.com"
[8]=>
string(26) "bhills_2852@mailinator.com"
[9]=>
string(26) "bhills_2852@mailinator.com"
}
["device_password"]=>
array(10) {
[0]=>
string(5) "Xkazi"
[1]=>
string(5) "Dwvso"
[2]=>
string(5) "Mdjxp"
[3]=>
string(5) "Pnnna"
[4]=>
string(5) "Cwtko"
[5]=>
string(5) "Dchoh"
[6]=>
string(5) "Paltd"
[7]=>
string(5) "Igzyo"
[8]=>
string(5) "Ubaio"
[9]=>
string(5) "Goiue"
}
}
我需要这个数组是像这个数组一样的新数组
array(7) {
[device_name]=>
string(13) "Beverly Hills"
[device_description]=>
string(5) "Trmqv"
[device_url]=>
string(22) "http://www.example.com"
[device_ip4]=>
string(5) "Rfxsi"
[device_ip6]=>
string(5) "Lcjui"
[device_username]=>
string(26) "bhills_0704@mailinator.com"
[device_password]=>
string(5) "Ilhdz"
}
您好我需要根据索引行
将此数组拆分为较小的新数组答案 0 :(得分:1)
这是一个动态解决方案,不需要您对密钥进行硬编码:
如果原始数据位于$device=array();
foreach($devices as $key=>$values) {
foreach($values as $index=>$value) {
$device[$index][$key] = $value;
}
}
:
$device
输出为{{1}}(单数)。
答案 1 :(得分:0)
感谢每一个人,使用array_map解决问题
$devices = array_map(null,
$device['device_name'],
$device['device_description'],
$device['device_url'],
$device['device_ip4'],
$device['device_ip6'],
$device['device_username'],
$device['device_password']
);
dd($devices);