How to convert json to php array object: First, the front-end js converts the object to json, the code is [var rows = JSON.stringify(rows);]; then the back-end php receives and converts it into an array, the code is 【if(count($uploadfiles) !=0)】.
Method of converting json to php array object:
Convert front-end js to json and pass it to php back-end, php Received in the background and converted into an array.
Effect:
Front-end js converts the object to json:
var rows = JSON.stringify(rows);
Backend php receives Convert to an array:
$uploadfiles = json_decode(stripslashes($_POST['uploadfile']), true); if(count($uploadfiles) != 0){ echo '有数据:'; echo count($uploadfiles); } else { echo '没有数据!'; }
Related learning recommendations: PHP programming from entry to proficiency
The above is the detailed content of How to convert json to php array object?. For more information, please follow other related articles on the PHP Chinese website!