<?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)));