How do I `json_encode()` keys from PHP array?

前端 未结 4 1669
鱼传尺愫
鱼传尺愫 2020-12-03 10:59

I have an array which prints like this

Array ( [0] => 1691864 [1] => 7944458 [2] => 9274078 [3] => 1062072 [4] => 8625335 [5] => 8255371 [6         


        
4条回答
  •  伪装坚强ぢ
    2020-12-03 11:39

    This is defined behaviour. The array you show is a non-associative, normally indexed array. Its indexes are implicitly numeric.

    If you decode the array in PHP or JavaScript, you will be able to access the elements using the index:

    $temp_array = json_decode($temp_json);
    
    echo $temp_array[2]; // 9274078
    

提交回复
热议问题