我想知道是否有任何PHP数组能够存储类似于以下javascript变量的数据结构' item'
var item = {id: 10, weight: "100g", qty: 1};
basketArray.push(item);
答案 0 :(得分:0)
$basketArray = array();
$basketArray['id'] = 10;
$basketArray['weight'] = '100g';
$basketArray['qty'] = 1;
答案 1 :(得分:0)
正常数组:
<?php
$array = [
"foo" => "bar",
"bar" => "foo",
];
?>
将元素推送到数组:
<?php
array_push($array, "barFoo", "fooBar");
?>