The problem with the array of PHP, ask for advice

// a
[1,2,3,4]
// b
["0"=>1, "1"=>2, "2"=>3, "3"=>4]

 a b php a   "" 
a  foreach   b

 a 

 a  b  json_encode() 
Php
Mar.28,2021

. Definitely different, an association, an index, in the json format display using {} [] to distinguish. Php has a function that can directly get all the values of the array, you can learn about it. Array_values


you can directly use array_values ($b) to return to the $an array;
don't worry about this problem later, it doesn't make much sense, and an is an indexed array, b is an associative array
and you correspond to an associative array in this numerical order, json_decode () is the same as the indexed array, that is, in the scenario above.


you can use array_values directly

Menu