這是我的多維關聯的JavaScript數組,我在PHP收到它:我如何訪問PHP中的多維關聯JS數組值?
array (size=2)
0 =>
object(stdClass)[1]
public 'count' => string '30' (length=2)
public 'size' => string '1' (length=0)
public 'name' => string 'aa' (length=0)
public 'pid' => string '910' (length=0)
public 'price' => string '300' (length=0)
1 =>
object(stdClass)[2]
public 'count' => string '30' (length=2)
public 'size' => string '2' (length=0)
public 'name' => string 'bb' (length=0)
public 'pid' => string '920' (length=0)
public 'price' => string '400' (length=0)
如何訪問多維關聯數組JS價值PHP?
問題的答案,但我有一個額外的註釋 - 我假設你用'json_decode()'在你的代碼,並得到了上述結果?如果是這樣,值得注意的是'json_decode()'默認爲JS對象文字創建'stdClass'對象實例。但是,您可以通過將'true'作爲第二個參數傳遞給'$ assoc'參數來強制執行PHP關聯數組;例如:'json_decode($ json,true);'。示例:https://eval.in/132718 - 更多關於'json_decode'的信息:http://www.php.net/manual/en/function.json-decode.php –