30 lines
455 B
PHP
30 lines
455 B
PHP
<?php
|
|
function array_to_object($tab)
|
|
{
|
|
$data = new stdClass;
|
|
if (is_array($tab) && !empty($tab) && !isNumericArray($tab))
|
|
{
|
|
foreach ($tab as $key => $val)
|
|
{
|
|
if (is_array($val)){
|
|
$data->$key = array_to_object($val);
|
|
} else {
|
|
$data->$key = $val;
|
|
}
|
|
}
|
|
} else {
|
|
$data = $tab;
|
|
}
|
|
return $data ;
|
|
}
|
|
|
|
function isNumericArray($tab)
|
|
{
|
|
$keys = array_keys($tab);
|
|
if (is_numeric($keys[0])){
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|