// -----------------------------------------------------------------------
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;
}
}