标签:php数组
array(2) { ["name"]=> array(2) { [0]=> string(8) "thinkphp" [1]=> string(8) "onethink" } ["email"]=> array(2) { [0]=> string(18) "thinkphp@gamil.com" [1]=> string(18) "onethink@gamil.com" } }
--------------------------------------------------------
转成:
array(2) { ["name"]=> array(2) { [0]=> string(8) "thinkphp" [1]=> string(8) "onethink" } ["email"]=> array(2) { [0]=> string(18) "thinkphp@gamil.com" [1]=> string(18) "onethink@gamil.com" } }
------------------------------------------------------
code:
$dataList[] = array(‘name‘=>‘thinkphp‘,‘email‘=>‘thinkphp@gamil.com‘);
$dataList[] = array(‘name‘=>‘onethink‘,‘email‘=>‘onethink@gamil.com‘);
echo ‘<pre>‘;
var_dump($dataList);
echo ‘</pre>‘;
echo ‘<hr>‘;
$dataList2[‘name‘] = array(‘0‘=>‘thinkphp‘,‘1‘=>‘onethink‘);
$dataList2[‘email‘] = array(‘0‘=>‘thinkphp@gamil.com‘,‘1‘=>‘onethink@gamil.com‘);
echo ‘<pre>‘;
var_dump($dataList2);
echo ‘</pre>‘;
echo ‘<hr>‘;
$tmp=array();
for($i=0;$i<2;$i++){
$tmp[$i][‘name‘]=$dataList2[‘name‘][$i];
$tmp[$i][‘email‘]=$dataList2[‘email‘][$i];
}
var_dump($tmp);
标签:php数组
原文地址:http://latecomer.blog.51cto.com/6509460/1812635