$jRegistry = new JRegistry(); $jRegistry->set('firstname', 'John'); $jRegistry->set('lastname', 'Doe'); $jRegistryArray = $jRegistry->toArray(); print_r($jRegistryArray);
Array ( [firstname] => John [lastname] => Doe )
$userData = '{"firstname":"John", "lastname":"Doe", "age":30}'; $jRegistry = new JRegistry($userData); $jRegistryArray = $jRegistry->toArray(); print_r($jRegistryArray);
Array ( [firstname] => John [lastname] => Doe [age] => 30 )In this example, we initialize the JRegistry object with a JSON string and then convert it to an array. The JRegistry class is part of the Joomla! Framework, which is a package library for building web applications.