数组长度相同,怎么把一个数组的键名变成第二个数组的键值
程序员文章站
2022-05-18 22:24:29
...
数组长度相同,如何把一个数组的键名变成第二个数组的键值。
比如我有$aa....$bb
$aa=Array ("0" =>"cd","1" =>"udd","2"=>"dsd");
$bb=Array ( "0" => 13ds,"1" =>"tdfestsdfa1","2" => "1122sdfdsasdf33abc") ;
把$aa数组的键名变成第二个数组$bb的键值。
如何形成如下数组¥cc。
$cc=Array ( "cd" => 13ds,"udd" =>"tdfestsdfa1","dsd" => "1122sdfdsasdf33abc") ;
请高人指点。
------解决思路----------------------
比如我有$aa....$bb
$aa=Array ("0" =>"cd","1" =>"udd","2"=>"dsd");
$bb=Array ( "0" => 13ds,"1" =>"tdfestsdfa1","2" => "1122sdfdsasdf33abc") ;
把$aa数组的键名变成第二个数组$bb的键值。
如何形成如下数组¥cc。
$cc=Array ( "cd" => 13ds,"udd" =>"tdfestsdfa1","dsd" => "1122sdfdsasdf33abc") ;
请高人指点。
------解决思路----------------------
$aa = Array("0" => "cd", "1" => "udd","2" => "dsd");
$bb = Array("0" => "13ds", "1" => "tdfestsdfa1", "2" => "1122sdfdsasdf33abc");
$cc = array_combine($aa, $bb);
print_r($cc);
$aa = Array("0" => "cd", "1" => "udd","2" => "dsd");
$bb = Array("0" => "13ds", "1" => "tdfestsdfa1", "2" => "1122sdfdsasdf33abc");
$cc = array_combine($aa, $bb);
print_r($cc);
相关文章
相关视频