{"id":7011,"date":"2024-11-14T11:45:23","date_gmt":"2024-11-14T03:45:23","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7011\/"},"modified":"2024-11-14T11:45:23","modified_gmt":"2024-11-14T03:45:23","slug":"%e4%ba%8c%e7%bb%b4%e6%95%b0%e7%bb%84%e4%b8%ad%e5%a6%82%e4%bd%95%e6%8c%89%e6%97%a5%e6%9c%9f%e9%94%ae%e5%90%8d%e5%90%88%e5%b9%b6%e6%95%b0%e6%8d%ae%e5%b9%b6%e6%b1%87%e6%80%bb%e6%95%b0%e6%8d%ae%e5%80%bc","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7011\/","title":{"rendered":"\u4e8c\u7ef4\u6570\u7ec4\u4e2d\u5982\u4f55\u6309\u65e5\u671f\u952e\u540d\u5408\u5e76\u6570\u636e\u5e76\u6c47\u603b\u6570\u636e\u503c\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173027584441019.jpg\" class=\"aligncenter\" title=\"\u4e8c\u7ef4\u6570\u7ec4\u4e2d\u5982\u4f55\u6309\u65e5\u671f\u952e\u540d\u5408\u5e76\u6570\u636e\u5e76\u6c47\u603b\u6570\u636e\u503c\uff1f\u63d2\u56fe\" alt=\"\u4e8c\u7ef4\u6570\u7ec4\u4e2d\u5982\u4f55\u6309\u65e5\u671f\u952e\u540d\u5408\u5e76\u6570\u636e\u5e76\u6c47\u603b\u6570\u636e\u503c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4e8c\u7ef4\u6570\u7ec4\u4e2d\u5982\u4f55\u6309\u952e\u540d\u5408\u5e76\u6570\u636e\uff1f<\/strong><\/p>\n<p>\u9700\u8981\u5c06\u7ed9\u5b9a\u7684\u4e8c\u7ef4\u6570\u7ec4\u8fdb\u884c\u5408\u5e76\uff0c\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\uff1a<\/p>\n<ul>\n<li>\u9ed8\u8ba4\u4ee5 6 \u4e2a\u4e3a\u5355\u4f4d\u8fdb\u884c\u5408\u5e76\uff0c\u82e5\u5c0f\u4e8e 6 \u4e2a\u5219\u6b63\u5e38\u5c55\u793a\u65e5\u671f<\/li>\n<li>\u5927\u4e8e 6 \u4e2a\u9700\u8981\u5408\u5e76\uff0c\u4f8b\u5982\u5c06 [22-02-05, 22-02-06, 22-02-07, 22-02-08, 22-02-09, 22-02-10] \u5408\u5e76\u4e3a 22-02-05\/22-02-10<\/li>\n<\/ul>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<pre>$arr = [\n    'categories' =&gt; [\n        '22-01-30',\n        '22-01-31',\n        '22-02-01',\n        '22-02-02',\n        '22-02-03',\n        '22-02-04',\n        '22-02-05',\n        '22-02-06',\n        '22-02-07',\n        '22-02-08',\n        '22-02-09',\n        '22-02-10',\n        '22-02-11',\n        '22-02-12',\n        '22-02-13',\n        '22-02-14',\n        '22-02-15',\n        '22-02-16',\n        '22-02-17',\n        '22-02-18',\n        '22-02-19',\n        '22-02-20',\n        '22-02-21',\n        '22-02-22',\n        '22-02-23',\n        '22-02-24',\n        '22-02-25',\n        '22-02-26',\n        '22-02-27',\n        '22-02-28',\n    ],\n    'data'       =&gt; [\n        '0',\n        '0',\n        '0',\n        '0',\n        '0',\n        '0',\n        '0',\n        '0',\n        '0',\n        '0',\n        '5638.04',\n        '0.00',\n        '0.00',\n        '0.00',\n        '0.00',\n        '0.00',\n        '0.00',\n        '0.00',\n        '0.00',\n        '0.00',\n        '0.00',\n        '0.00',\n        '0.00',\n        '0.00',\n        '25915.99',\n        '1606.44',\n        '1676.90',\n        '0.00',\n        '0.00',\n        '1203.08',\n    ],\n];\n\n$chunk = 6;\n\n$result = array_reduce(array_chunk($arr['categories'], $chunk), function ($result, $current) use ($chunk, $arr) {\n    $start = current($current);\n    $end = end($current);\n    $result['categories'][] = $start . '\/' . $end;\n\n    $count = count($result['categories'] ?? []);\n    $result['data'][] = array_sum(array_slice($arr['data'] ?? [], $count * $chunk, $chunk));\n\n    return $result;\n}, ['categories' =&gt; [], 'data' =&gt; []]);\n\nvar_dump($result, (array_sum($arr['data']) === array_sum($result['data'])));<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4e8c\u7ef4\u6570\u7ec4\u4e2d\u5982\u4f55\u6309\u65e5\u671f\u952e\u540d\u5408\u5e76\u6570\u636e\u5e76\u6c47\u603b\u6570\u636e\u503c\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e8c\u7ef4\u6570\u7ec4\u4e2d\u5982\u4f55\u6309\u952e\u540d\u5408\u5e76\u6570\u636e\uff1f \u9700\u8981\u5c06\u7ed9\u5b9a\u7684\u4e8c\u7ef4\u6570\u7ec4\u8fdb\u884c\u5408\u5e76\uff0c\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\uff1a \u9ed8\u8ba4\u4ee5 6 \u4e2a\u4e3a\u5355\u4f4d\u8fdb\u884c\u5408\u5e76\uff0c\u82e5\u5c0f\u4e8e 6 \u4e2a\u5219\u6b63\u5e38\u5c55\u793a\u65e5\u671f \u5927\u4e8e 6 \u4e2a\u9700\u8981\u5408\u5e76\uff0c\u4f8b\u5982\u5c06 [22-02-05, 22-02-06, 22-02-07, 22-02-08, 22-02-09, 22-02-10] \u5408\u5e76\u4e3a 22-02-05\/22-02-10 \u89e3\u51b3\u65b9\u6848\uff1a $arr = [ &#8216;categories&#8217; =&gt; [ &#8217;22-01-30&#8242;, &#8217;22-01-31&#8242;, &#8217;22-02-01&#8242;, &#8217;22-02-02&#8242;, &#8217;22-02-03&#8242;, &#8217;22-02-04&#8242;, &#8217;22-02-05&#8242;, &#8217;22-02-06&#8242;, &#8217;22-02-07&#8242;, &#8217;22-02-08&#8242;, &#8217;22-02-09&#8242;, &#8217;22-02-10&#8242;, &#8217;22-02-11&#8242;, &#8217;22-02-12&#8242;, &#8217;22-02-13&#8242;, &#8217;22-02-14&#8242;, &#8217;22-02-15&#8242;, &#8217;22-02-16&#8242;, &#8217;22-02-17&#8242;, &#8217;22-02-18&#8242;, &#8217;22-02-19&#8242;, &#8217;22-02-20&#8242;, &#8217;22-02-21&#8242;, &#8217;22-02-22&#8242;, &#8217;22-02-23&#8242;, &#8217;22-02-24&#8242;, &#8217;22-02-25&#8242;, &#8217;22-02-26&#8242;, &#8217;22-02-27&#8242;, &#8217;22-02-28&#8242;, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-7011","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7011","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=7011"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7011\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7011"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7011"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7011"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}