{"id":405,"date":"2020-10-17T02:38:33","date_gmt":"2020-10-16T18:38:33","guid":{"rendered":"http:\/\/log.tanxiaodian.com\/?p=405"},"modified":"2020-10-17T02:38:33","modified_gmt":"2020-10-16T18:38:33","slug":"%e5%85%83%e7%b4%a0%e4%b8%ba-%e5%af%b9%e8%b1%a1%e5%92%8c%e6%95%b0%e7%bb%84-%e7%9a%84%e6%95%b0%e7%bb%84%e5%8c%ba%e5%88%ab%e4%be%8b%e5%ad%90","status":"publish","type":"post","link":"https:\/\/log.tanxiaodian.com\/?p=405","title":{"rendered":"\u5143\u7d20\u4e3a \u5bf9\u8c61\u548c\u6570\u7ec4  \u7684\u6570\u7ec4\u533a\u522b\u4f8b\u5b50"},"content":{"rendered":"\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container\">\n<p>&lt;?php<br>class User{<br>      public $id;<br>      public $name;<\/p>\n<\/div><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>    function __construct($id, $name) {\n        $this->id = $id;\n        $this->name = $name;\n    }<\/code><\/pre>\n\n\n\n<p>}<\/p>\n\n\n\n<p>$arrUser = [<br>new User(1,&#8217;zc&#8217;),<br>new User(2,&#8217;xhd&#8217;),<br>new User(3,&#8217;pp&#8217;),<br>new User(4,&#8217;zl&#8217;),<br>];<\/p>\n\n\n\n<p>function processObj($arr)<br>{<br>foreach($arr as $item) {<br>$item-&gt;name .= &#8216;_man&#8217;;<br>}<br>}<\/p>\n\n\n\n<p>function processArr($arr)<br>{<br>foreach($arr as $item) {<br>$item[&#8216;b&#8217;] .= &#8216;_man&#8217;;<br>}<br>}<\/p>\n\n\n\n<p>$arrTest = [<br>[&#8216;a&#8217; =&gt; 1, &#8216;b&#8217; =&gt; 2],<br>[&#8216;a&#8217; =&gt; 3, &#8216;b&#8217; =&gt; 4],<br>[&#8216;a&#8217; =&gt; 5, &#8216;b&#8217; =&gt; 6],<br>];<\/p>\n\n\n\n<p>processObj($arrUser);<br>var_dump($arrUser);<\/p>\n\n\n\n<p>processArr($arrTest);<br>var_dump($arrTest);<\/p>\n\n\n\n<p>\u4ece\u8f93\u51fa\u7ed3\u679c \u53ef\u4ee5\u770b\u5230$arrUser\u5185\u5bb9\u53d1\u751f\u4e86\u6539\u53d8  $arrTest\u5185\u5bb9\u6ca1\u6709\u6539\u53d8<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&lt;?phpclass User{ publi&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/log.tanxiaodian.com\/?p=405\">Continue reading<span class=\"screen-reader-text\">\u5143\u7d20\u4e3a \u5bf9\u8c61\u548c\u6570\u7ec4  \u7684\u6570\u7ec4\u533a\u522b\u4f8b\u5b50<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[30,29],"_links":{"self":[{"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/posts\/405"}],"collection":[{"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=405"}],"version-history":[{"count":1,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/posts\/405\/revisions"}],"predecessor-version":[{"id":406,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/posts\/405\/revisions\/406"}],"wp:attachment":[{"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}