Monday 18 April 2016

PHP function to convert Multidimensional Arrays to stdClass Objects

PHP function to convert Multidimensional Arrays to stdClass Objects

<?php
    function array2object($myarray) {
        if (is_array($myarray)) {
            return (object) array_map(__FUNCTION__, $myarray);
        }
        else {
            return $myarray;
        }
    }
?>

No comments:

Post a Comment