-2
我需要PHP陣列的JS數組,具體格式,如:把PHP對象的JavaScript數組
products = [{}, {}, {}]
我一直在谷歌2天,並試圖用PHP函數json_encode,但它不」 t給我我想要的格式。 我得到這個:
Array
(
[0] => Array
(
[id] => 3971
[name] => Test
[price] => 1107.9000
[brand] => KM
[variant] =>
[quantity] => 3.27
)
[1] => Array
(
[id] => 3957
[name] => Test
[price] => 87.3000
[brand] => KM
[variant] =>
[quantity] => 4
)
)
對不起,愚蠢的重複問題。
使用** ** json_encode和閱讀本http://php.net/manual/en/function.json -encode.php –
當你使用'json_encode()'時,你不會得到你所描述的。 – DanFromGermany