From: 67671047
When using the TP5 framework to do projects, queries for data return objects, although they can also be traversed as normal arrays for subsequent processing, but this form is thrown directly to the front end or I want to temporarily add a data field to the returned result, and this JSON object array form is OK. Temporary data fields are not included in the object array, so converting to a normal array can be easier to handle.
<? PHP Public function Scandata () { = model ('datacount'); = $model all (); return JSON ($DATA); }
After calling Sandata () in the same controller or class, we get an array of JSON objects, like this, if the front-end directly requests this method, the data in JSON format is obtained.
Processed into an ordinary array:
Method ①
= $ this , Jsondatacount (); = Json_decode ($list->getcontent (),true);
Method ②
$list = $ this
The results are similar to this after processing:
TP5 an array of JSON objects into a normal array