Pay attention to json_encode after phparray_unique. For example: array_unique (array (, 2); the result is array (2) {[0] int (1) [2] int (2 )} this is not a numeric array. if json_encode is directly used, a json object is output instead of array_unique (array (1, 1, 2 ));
The result is
Array (2 ){
[0] =>
Int (1)
[2] =>
Int (2)
}
This is not a numeric array. json_encode is directly used to output a json object instead of an array.
{"0": 1, "2": 2}
If the js on the page needs an array data format of [1, 2] At this time, an error may occur.
After array_unique, create an array_values
In this way, array_values (array_unique (array (1, 1, 2 )));
The result is [1, 2].
Struct (array (1, 1, 2); the result is array (2) {[0] = int (1) [2] = int (2 )} this is not a numeric array. json_encode is directly used to output a json object instead...