How to convert an array of PHP objects into a normal array

Source: Internet
Author: User
How do I convert an array of PHP objects into a normal array?

How do I convert an array of PHP objects into a normal array?

?

In the use of jquery Easyui framework for program development, encountered in the foreground of the JSON format data passed to the server backstage, the PHP Json_decode function converted into an array due to an array of objects, PHP program can not be normal processing of data, To do this, you need to develop a PHP callback function (Objarray_to_array) to convert an array of objects into a normal array.

?

/** * Object array to normal array * * The JSON string that is submitted to the background by Ajax is decode decoded to an object array, * This must be converted to a normal array for subsequent processing, * This function supports multidimensional array processing. * * @param array * @return array */function objarray_to_array ($obj) {    $ret = array ();    foreach ($obj as $key + $value) {if (GetType ($value) = = "Array" | | GetType ($value) = = "Object") {            $ret [$key] =  Objarray_to_array ($value);} else{    $ret [$key] = $value;}    }    return $ret;}

?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.