zoukankan      html  css  js  c++  java
  • php object转数组示例

    原本是这样格式的数据:

    object(ThriftServerPageCards)#32 (3) {
      ["cards"]=>
      array(10) {
        [0]=>
        object(ThriftServerCards)#33 (8) {
          ["id"]=>
          int(170)
          ["packageID"]=>
          int(4)
          ["ccID"]=>
          string(19) "898601137211040433n"
          ["telephone"]=>
          string(11) "1452006059n"
          ["batch"]=>
          string(1) "1"
          ["producedAt"]=>
          string(19) "2014-12-31 00:00:00"
          ["development"]=>
          int(0)
          ["status"]=>
          int(1)
        }
    }
    }

    通过这个方法可以转换为php数组形式

    function std_class_object_to_array($stdclassobject)
    {
        $_array = is_object($stdclassobject) ? get_object_vars($stdclassobject) : $stdclassobject;
        foreach ($_array as $key => $value) {
            $value = (is_array($value) || is_object($value)) ? std_class_object_to_array($value) : $value;
            $array[$key] = $value;
        }
        return $array;
    }
  • 相关阅读:
    Scrapy中间件
    Scrapy简介
    Scrapy解析器xpath
    postman
    yarn
    brew 安装 yarn 时候失败
    immutability-helper 用途+使用方法
    js 正则
    react redux 应用链接
    react 事件传参数
  • 原文地址:https://www.cnblogs.com/xiaoyueer/p/4308693.html
Copyright © 2011-2022 走看看