I have code like this, that initialize config
$this->config = array(
'users' => array(
array('name' => 'admin',
'password' => $password
)
),
'tokens' => array(),
'sessions' => array(),
);
that I’m saving to a file using json_encode($this->config) and later I load it using
json_decode(file_get_contents('file.json'));
it create nested objects, I would like to have this nested object when I initialize and the config, is there a way to create this nested object other then this?
$this->config = json_decode(json_encode($this->config));
I decide to use this function instead
and explicitly call it for assoc arrays
EDIT recursive code