Posts Tagged ‘stdClass Object’

Convert array to object and object to array in PHP

by on Thursday, November 1st, 2012

convert array to object PHP

$obj = json_decode (json_encode ($var), FALSE);
where $var is an array.

convert object to array PHP

$arr = json_decode( json_encode($var), true);
where $var is an object