2015-05-25 130 views
-2

我想知道是否有任何PHP數組,它是能夠存儲類似於下面JavaScript變量「項」PHP對象陣列

var item = {id: 10, weight: "100g", qty: 1}; 
basketArray.push(item); 

回答

0
$basketArray = array(); 

$basketArray['id'] = 10; 
$basketArray['weight'] = '100g'; 
$basketArray['qty'] = 1; 
0

正常陣列的數據結構組成:

<?php 
    $array = [ 
     "foo" => "bar", 
     "bar" => "foo", 
    ]; 
?> 

推動元件到陣列:

<?php 
    array_push($array, "barFoo", "fooBar"); 
?>