// The manual specifies the second argument of json_decode as:
// assoc
// When TRUE, returned objects will be converted into associative arrays.
$array = json_decode(json_encode($booking), true);
//Array after (object)
$clasa = (object) array(
'e1' => array('nume' => 'Nitu', 'prenume' => 'Andrei', 'sex' => 'm', 'varsta' => 23),
'e2' => array('nume' => 'Nae', 'prenume' => 'Ionel', 'sex' => 'm', 'varsta' => 27),
'e3' => array('nume' => 'Noman', 'prenume' => 'Alice', 'sex' => 'f', 'varsta' => 22),
'e4' => array('nume' => 'Geangos', 'prenume' => 'Bogdan', 'sex' => 'm', 'varsta' => 23),
'e5' => array('nume' => 'Vasile', 'prenume' => 'Mihai', 'sex' => 'm', 'varsta' => 25)
);
$person = new stdClass();
$person->firstName = "Taylor";
$person->age = 32;
//Convert Single-Dimention Object to array
$personArray = (array) $person;
//Convert Multi-Dimentional Object to Array
$personArray = objectToArray($person);
function objectToArray ($object) {
if(!is_object($object) && !is_array($object)){
return $object;
}
return array_map('objectToArray', (array) $object);
}
<?php
$empInfo = array(
'name'=>'John',
'address'=>'Houston',
'employment' => array(
'id' => '1',
'address' => 'Los Angeles'
)
);
// or
$obj = (obj)['name'=> 'Jone Doe'];
print_r(json_decode(json_encode($empInfo)));