All the tutorials I read are on the server echostring... output a string and hand it to the front-end js for processing. I would like to ask how to get a search page that returns dozens of results at once? Whether to return a string, then cut it into an array, and then process it again, or php can... all the tutorials I have read are output a string on the server echo string,
And then hand it to the front-end js for processing.
I would like to ask how to get a search page that returns dozens of results at once?
Is to return a string, then cut it into an array, and then process it,
Or can php directly return an object or an array?
Reply content:
All the tutorials I have read are a string generated on the server echo string,
And then hand it to the front-end js for processing.
I would like to ask how to get a search page that returns dozens of results at once?
Is to return a string, then cut it into an array, and then process it,
Or can php directly return an object or an array?
PHPecho
The output is a string, but you can usejson_encode
If an array is formatted as a json string, multiple messages can be returned.
$data = [];$data[] = 'data1';$data[] = 'data2';$data[] = 'data3';$data[] = 'data4';$str = json_encode($data);echo $str;exit;
The front-end obtains an array object.
Json can be an array .. For example, you don't need paging.
Returns an array. after parsing, the array can contain a lot of json. then, you can create an appropriate number of html elements based on the array length.
Return json data
Returnjson
Orxml
Format data, first pushjson
.
Returns the json Array and then traverses it.
I personally think it is complicated to process the client webpage (android, ios, etc.). if it is too complicated, the server generates HTML responses.
Otherwise, all are returned.json
Format data, processed by the customer service endjson_encode($list);
Of course, returnxml
Yes, but as you can seejson
Is mainstream,php
Operationjson
Easy to use