Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter HMVC error
#4

Place in a CodeIgniter Help file.

PHP Code:
// -----------------------------------------------------------------------

if ( ! function_exists('objectToArray'))
{
    
/**
     * objectToArray ()
     * -------------------------------------------------------------------
     *
     * @param  $data
     * @return array
     */
    
function objectToArray($data)
    {
        if (
is_object($data))
        {
            
/**
             * Gets the properties of the given object
             * with get_object_vars function
             */
            
$data get_object_vars($data);
        }

        
/**
         * Return array converted to object Using __FUNCTION__ (Magic constant)
         * for recursive call
         */
        
return (is_array($data))
            ? 
array_map(__FUNCTION__$data)
            : 
$data;
    }
}

// -----------------------------------------------------------------------

if ( ! function_exists('arrayToObject'))
{
    
/**
     * arrayToObject ()
     * -------------------------------------------------------------------
     *
     * @param  $data
     * @return object
     */
    
function arrayToObject($data)
    {
        
/**
         * Return array converted to object Using __FUNCTION__ (Magic constant)
         * for recursive call
         */
        
return (is_array($data))
            ? (object) 
array_map(__FUNCTION__$data)
            : 
$data;
    }

What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
CodeIgniter HMVC error - by azmath - 06-08-2018, 10:01 PM
RE: CodeIgniter HMVC error - by InsiteFX - 06-09-2018, 04:01 AM
RE: CodeIgniter HMVC error - by TamasD - 07-15-2018, 12:36 PM
RE: CodeIgniter HMVC error - by InsiteFX - 07-17-2018, 05:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB