Daily bug (1)

  Today, at the time of writing the code, front-end to me, that I have to write an interface may be a problem. Leading to the front of the data does not display properly, I went to see it, and indeed can not be displayed properly. The problem is that the original front-end loop through the array in a json, but then the data becomes a target. Well, then the code.

$ ARR = [ 
    0 => 'A', 
    . 1 => 'B', 
    2 => 'C', 
    . 3 => 'D', 
]; 
$ the Add = [ 
    . 5 => 'E', 
    . 6 => 'F ', 
    . 7 =>' G ', 
]; 
$ List = []; 
// business needs additional data into 
the array_push (List $, $ ARR); 
the array_push ($ List, the Add $); echo' <pre> ' ; 
print_r ($ List);

  Code is nothing special, the result is no accident, of course, is a two-dimensional array, the result of:

  However, I need to return a json format data, code:

$ ARR = [ 
    0 => 'A', 
    . 1 => 'B', 
    2 => 'C', 
    . 3 => 'D', 
]; 
$ the Add = [ 
    . 5 => 'E', 
    . 6 => 'F ', 
    . 7 =>' G ', 
]; 
$ List = []; 
// business needs additional data into 
the array_push (List $, $ ARR); 
the array_push ($ List, the Add $); 
echo' <pre> ' ; 
// print_r ($ List); 
var_dump (json_encode ($ List));

  Print Results:

  As a result, the second array into a subject. And finally found the ultimate cause is the second array indices, not 0, will lead to a second array when it turns json, will become a target. Finally, the index modified second set of data, the results have become normal array.

Guess you like

Origin www.cnblogs.com/fuyunqishi/p/11140895.html