Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

比如多个一维数组如下。
array(2) {
["address"] => string(6) "广东"
["tongji"] => string(1) "10"
}
array(2) {
["address"] => string(9) "深圳"
["tongji"] => string(1) "2"
}
array(2) {
["address"] => string(6) "广州"
["tongji"] => string(1) "4"
}

转换成如下二维数组
array(3) {

[1] => array(2) {
  ["address"] => string(6) "广东"
  ["tongji"] => string(1) "10"

}

[2] => array(2) {
  ["address"] => string(9) "深证"
  ["tongji"] => string(1) "2"
}
[] => array(2) {
  ["address"] => string(6) "广州"
  ["tongji"] => string(1) "4"
}

}


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
509 views
Welcome To Ask or Share your Answers For Others

1 Answer

array_push函数

$a = array(
    "address" =>  "广东",
);

$b = array(
    "address" =>  "深圳",
);
$c = array(
    "address" =>  "北京",
);
$rs = [];
array_push($rs,$a, $b,$c);
print_r($rs);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...