json_encode/json_decode - returns stdClass instead of Array in PHP

前端 未结 7 2214
太阳男子
太阳男子 2020-12-04 13:54

Observe this little script:

$array = array(\'stuff\' => \'things\');
print_r($array);
//prints - Array ( [stuff] => things )
$arrayEncoded = json_encod         


        
7条回答
  •  盖世英雄少女心
    2020-12-04 14:37

    tl;dr: JavaScript doesn't support associative arrays, therefore neither does JSON.

    After all, it's JSON, not JSAAN. :)

    So PHP has to convert your array into an object in order to encode into JSON.

提交回复
热议问题