示例#1
0
 function decode($text, $type = 0)
 {
     if (empty($text)) {
         return '';
     } elseif (!is_string($text)) {
         return false;
     }
     $this->at = 0;
     $this->ch = '';
     $this->text = strtr(stripslashes($text), array("\r" => '', "\n" => '', "\t" => '', "\\b" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "\v" => '', "\f" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => ''));
     $this->next();
     $return = $this->val();
     $result = empty($type) ? $return : get_object_vars_deep($return);
     return $result;
 }
示例#2
0
/**
 * 返回由对象属性组成的关联数组
 *
 * @access   pubilc
 * @param    obj    $obj
 *
 * @return   array
 */
function get_object_vars_deep($obj)
{
    if (is_object($obj)) {
        $obj = get_object_vars($obj);
    }
    if (is_array($obj)) {
        foreach ($obj as $key => $value) {
            $obj[$key] = get_object_vars_deep($value);
        }
    }
    return $obj;
}
示例#3
0
 function ecm_json_decode($value, $type = 0)
 {
     if (CHARSET == 'utf-8' && function_exists('json_decode')) {
         return empty($type) ? json_decode($value) : get_object_vars_deep(json_decode($value));
     }
     if (!class_exists('JSON')) {
         import('json.lib');
     }
     $json = new JSON();
     return $json->decode($value, $type);
 }