function encode_json($data) { // Use PEAR's Services_JSON encoder $json = new SEServices_JSON(); return $json->encode($data); }