{"id":570,"date":"2025-06-11T09:44:48","date_gmt":"2025-06-11T01:44:48","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/php\/php-application-manual\/sjjg\/570.html"},"modified":"2025-06-11T09:44:48","modified_gmt":"2025-06-11T01:44:48","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8-php-%e4%b8%ad%e7%a7%bb%e9%99%a4%e6%95%b0%e7%bb%84%e4%b8%ad%e7%9a%84%e7%a9%ba%e5%85%83%e7%b4%a0","status":"publish","type":"my1js","link":"https:\/\/www.zhaozhao123.cn\/php\/my1js\/570.html","title":{"rendered":"\u5982\u4f55\u5728 PHP \u4e2d\u79fb\u9664\u6570\u7ec4\u4e2d\u7684\u7a7a\u5143\u7d20"},"content":{"rendered":"<div class=\"wp-block-columns p-0 border is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-columns px-4 py-3 border-bottom has-background is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\" style=\"background:linear-gradient(243deg,rgb(238,238,238) 0%,rgba(58,166,242,0.15) 100%)\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\r\n<figure class=\"wp-block-image size-thumbnail is-resized is-style-rounded is-style-rounded--1\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/dyA-1-400x300.jpg\" alt=\"Bug&#32534;&#35793;&#29422;\" class=\"wp-image-1842\" style=\"object-fit:cover;width:30px;height:30px\"><\/figure>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading my-0\" style=\"font-size:clamp(0.875rem, 0.875rem + ((1vw - 0.2rem) * 0.175), 1rem);\">Bug&#32534;&#35793;&#29422;<\/h2>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns px-xl-5 px-4 py-xl-4 py-3 is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<p>&#22312; PHP &#20013;&#65292;&#22914;&#26524;&#20320;&#24819;&#20174;&#25968;&#32452;&#20013;&#31227;&#38500;&#25152;&#26377;&#31354;&#20803;&#32032;&#65288;&#21253;&#25324; <code>null<\/code>&#12289;<code>0<\/code>&#12289;&#31354;&#23383;&#31526;&#20018;&#21644;&#31354;&#25968;&#32452;&#65289;&#65292;&#20320;&#21487;&#20197;&#20351;&#29992;&#22810;&#31181;&#26041;&#27861;&#12290;&#20197;&#19979;&#26159;&#20960;&#31181;&#24120;&#35265;&#30340;&#26041;&#27861;&#65306;<\/p>\n<h3>&#26041;&#27861;&#19968;&#65306;&#20351;&#29992; <code>array_filter<\/code><\/h3>\n<p><code>array_filter<\/code> &#20989;&#25968;&#21487;&#20197;&#29992;&#26469;&#36807;&#28388;&#25481;&#25968;&#32452;&#20013;&#30340;&#31354;&#20540;&#12290;<\/p>\n<pre><code class=\"language-php\">$array = [1, 2, null, '', [], 3];\n$filteredArray = array_filter($array);\nprint_r($filteredArray); \/\/ &#36755;&#20986;: Array ( [0] =&gt; 1 [1] =&gt; 2 [3] =&gt; 3 )<\/code><\/pre>\n<h3>&#26041;&#27861;&#20108;&#65306;&#20351;&#29992; <code>array_values<\/code> &#21644; <code>array_diff_key<\/code><\/h3>\n<p><code>array_values<\/code> &#20989;&#25968;&#21487;&#20197;&#37325;&#26032;&#32034;&#24341;&#25968;&#32452;&#20013;&#30340;&#38190;&#65292;&#28982;&#21518;&#20351;&#29992; <code>array_diff_key<\/code> &#20989;&#25968;&#26469;&#25490;&#38500;&#38190;&#20026; <code>0<\/code> &#30340;&#39033;&#12290;<\/p>\n<pre><code class=\"language-php\">$array = [1, 2, null, '', [], 3];\n$filteredArray = array_values(array_diff_key($array, ['0' =&gt; '']));\nprint_r($filteredArray); \/\/ &#36755;&#20986;: Array ( [0] =&gt; 1 [1] =&gt; 2 [3] =&gt; 3 )<\/code><\/pre>\n<h3>&#26041;&#27861;&#19977;&#65306;&#20351;&#29992;&#27491;&#21017;&#34920;&#36798;&#24335;<\/h3>\n<p>&#22914;&#26524;&#20320;&#21482;&#24819;&#31227;&#38500;&#31354;&#23383;&#31526;&#20018;&#21644;&#31354;&#25968;&#32452;&#65292;&#21487;&#20197;&#20351;&#29992;&#27491;&#21017;&#34920;&#36798;&#24335;&#12290;<\/p>\n<pre><code class=\"language-php\">$array = [1, 2, null, '', [], 3];\n$filteredArray = array_filter($array, function($value) {\n    return !is_string($value) || $value !== '';\n});\nprint_r($filteredArray); \/\/ &#36755;&#20986;: Array ( [0] =&gt; 1 [1] =&gt; 2 [3] =&gt; 3 )<\/code><\/pre>\n<h3>&#31034;&#20363;&#20195;&#30721;<\/h3>\n<p>&#20197;&#19979;&#26159;&#19968;&#20010;&#23436;&#25972;&#30340;&#31034;&#20363;&#20195;&#30721;&#65292;&#23637;&#31034;&#20102;&#22914;&#20309;&#20351;&#29992;&#36825;&#20123;&#26041;&#27861;&#26469;&#31227;&#38500;&#25968;&#32452;&#20013;&#30340;&#31354;&#20803;&#32032;&#65306;<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\n$array = [1, 2, null, '', [], 3];\n\n\/\/ &#20351;&#29992; array_filter\n$filteredArray1 = array_filter($array);\necho \"Using array_filter:n\";\nprint_r($filteredArray1);\n\n\/\/ &#20351;&#29992; array_values &#21644; array_diff_key\n$filteredArray2 = array_values(array_diff_key($array, ['0' =&gt; '']));\necho \"nUsing array_values and array_diff_key:n\";\nprint_r($filteredArray2);\n\n\/\/ &#20351;&#29992;&#27491;&#21017;&#34920;&#36798;&#24335;\n$filteredArray3 = array_filter($array, function($value) {\n    return !is_string($value) || $value !== '';\n});\necho \"nUsing regular expression:n\";\nprint_r($filteredArray3);\n?&gt;<\/code><\/pre>\n<p>&#36816;&#34892;&#36825;&#27573;&#20195;&#30721;&#23558;&#36755;&#20986;&#65306;<\/p>\n<pre><code>Using array_filter:\nArray\n(\n    [0] =&gt; 1\n    [1] =&gt; 2\n    [3] =&gt; 3\n)\n\nUsing array_values and array_diff_key:\nArray\n(\n    [0] =&gt; 1\n    [1] =&gt; 2\n    [3] =&gt; 3\n)\n\nUsing regular expression:\nArray\n(\n    [0] =&gt; 1\n    [1] =&gt; 2\n    [3] =&gt; 3\n)<\/code><\/pre>\n<p>&#36890;&#36807;&#36825;&#20123;&#26041;&#27861;&#65292;&#20320;&#21487;&#20197;&#36731;&#26494;&#22320;&#20174; PHP &#25968;&#32452;&#20013;&#31227;&#38500;&#31354;&#20803;&#32032;&#12290;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div><div class=\"wp-block-columns p-0 border is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-columns px-4 py-3 border-bottom has-background is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\" style=\"background:linear-gradient(243deg,rgb(238,238,238) 0%,rgba(58,166,242,0.15) 100%)\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\r\n<figure class=\"wp-block-image size-thumbnail is-resized is-style-rounded is-style-rounded--2\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/zp-400x300.jpg\" alt=\"&#40657;&#26495;Bug&#35762;&#24072;\" class=\"wp-image-1849\" style=\"object-fit:cover;width:30px;height:30px\"><\/figure>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading my-0\" style=\"font-size:clamp(0.875rem, 0.875rem + ((1vw - 0.2rem) * 0.175), 1rem);\">&#40657;&#26495;Bug&#35762;&#24072;<\/h2>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns px-xl-5 px-4 py-xl-4 py-3 is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<body><h2>&#20171;&#32461;<\/h2><p>&#25968;&#32452;&#26159;PHP&#20013;&#30340;&#19968;&#20010;&#22522;&#26412;&#32452;&#25104;&#37096;&#20998;&#65292;&#29992;&#20110;&#24320;&#21457;Web&#24212;&#29992;&#31243;&#24207;&#30340;&#26381;&#21153;&#22120;&#31471;&#33050;&#26412;&#35821;&#35328;&#12290;&#23545;&#25968;&#32452;&#30340;&#36866;&#24403;&#31649;&#29702;&#33267;&#20851;&#37325;&#35201;&#65292;&#21253;&#25324;&#36807;&#28388;&#31354;&#20803;&#32032;&#65292;&#36825;&#23545;&#20110;&#25552;&#39640;&#24615;&#33021;&#21644;&#20934;&#30830;&#24615;&#22312;PHP&#24212;&#29992;&#20013;&#38750;&#24120;&#37325;&#35201;&#12290;<\/p><p>&#22312;PHP&#20013;&#65292;&#25968;&#32452;&#21487;&#20197;&#21253;&#21547;&#31354;&#20803;&#32032;&#65292;&#36890;&#24120;&#20026;&#31354;&#23383;&#31526;&#20018;&#65288;&#8221;&#8221;&#65289;&#65292;NULL&#65292;&#29978;&#33267;&#26410;&#21021;&#22987;&#21270;&#30340;&#20803;&#32032;&#12290;&#36825;&#20123;&#20803;&#32032;&#21487;&#33021;&#26159;&#30001;&#20110;&#25968;&#25454;&#22788;&#29702;&#12289;&#29992;&#25143;&#36755;&#20837;&#25110;&#26576;&#20123;&#25968;&#32452;&#25805;&#20316;&#30340;&#32467;&#26524;&#12290;&#20102;&#35299;&#22914;&#20309;&#31227;&#38500;&#36825;&#20123;&#20803;&#32032;&#20197;&#30830;&#20445;&#25968;&#32452;&#30340;&#25968;&#25454;&#23436;&#25972;&#24615;&#33267;&#20851;&#37325;&#35201;&#12290;<\/p><h2>&#22522;&#26412;&#25216;&#26415;<\/h2><h3>&#20351;&#29992;&#12290;<code>array_filter()<\/code><\/h3><p>&#19968;&#31181;&#31616;&#21333;&#30340;&#26041;&#27861;&#26159;&#20351;&#29992;&#20869;&#32622;&#30340;&#36807;&#28388;&#22120;&#26469;&#21435;&#38500;&#25968;&#32452;&#20013;&#30340;&#31354;&#20803;&#32032;&#12290;<code>array_filter()<\/code>&#40664;&#35748;&#24773;&#20917;&#19979;&#65292;<code>array_filter()<\/code>&#20174;&#19968;&#20010;&#25968;&#32452;&#20013;&#31227;&#38500;&#25152;&#26377;&#31561;&#20110;&#26576;&#20010;&#20540;&#30340;&#20803;&#32032;&#12290;<code>false<\/code>&#21253;&#25324;&#31354;&#23383;&#31526;&#20018;&#22312;&#20869;&#30340;&#65292;<code>NULL<\/code>&#22909;&#30340;&#65292;&#35831;&#21457;&#36865;&#20320;&#38656;&#35201;&#32763;&#35793;&#30340;&#20869;&#23481;&#12290;<code>0<\/code>&#21644;&#25105;&#25171;&#25307;&#21628;&#21543;&#12290;<code>false<\/code>&#33258;&#36523;&#12290;<\/p><pre><code>&lt;?php\n$array = array(\"apple\", \"\", \"banana\", NULL, \"0\", \"orange\", false);\n$filtered_array = array_filter($array);\nprint_r($filtered_array);\n\/\/ Output:\n\/\/ Array\n\/\/ (\n\/\/     [0] =&gt; apple\n\/\/     [2] =&gt; banana\n\/\/     [5] =&gt; orange\n\/\/ )\n?&gt;<\/code><\/pre><p>&#27880;&#24847;&#65292;&#38500;&#20102;&#31354;&#23383;&#31526;&#20018;&#21644;NULL&#20043;&#22806;&#65292;&#25968;&#23383;&#20018;&ldquo;0&rdquo;&#21644;FALSE&#20063;&#34987;&#21024;&#38500;&#20102;&#12290;<\/p><h3>&#20445;&#23384;&#23494;&#38053;<\/h3><p>&#40664;&#35748;&#24773;&#20917;&#19979;&#65292;<code>array_filter()<\/code>&#19981;&#20445;&#30041;&#25968;&#23383;&#38190;&#12290;&#22914;&#26524;&#20320;&#30340;&#25968;&#32452;&#21253;&#21547;&#38656;&#35201;&#20445;&#25345;&#30340;&#25968;&#23383;&#38190;&#65292;&#20320;&#21487;&#20197;&#20256;&#36882;&#31532;&#20108;&#20010;&#21442;&#25968;&#12290;<code>ARRAY_FILTER_USE_BOTH<\/code>&#65292;&#20197;&#20445;&#30041;&#21407;&#22987;&#25968;&#32452;&#30340;&#38190;&#12290;<\/p><pre><code>&lt;?php\n$array = array(1 =&gt; \"apple\", 2 =&gt; \"\", 3 =&gt; \"banana\", 4 =&gt; NULL);\n$filtered_array = array_filter($array, fn($value, $key) =&gt; !empty($value) || $key === 2, ARRAY_FILTER_USE_BOTH);\nprint_r($filtered_array);\n\/\/ Output:\n\/\/ Array\n\/\/ (\n\/\/     [1] =&gt; apple\n\/\/     [3] =&gt; banana\n\/\/ )\n?&gt;<\/code><\/pre><p>&#36825;&#20250;&#20445;&#30041;&#38190;&#65292;&#20294;&#35831;&#27880;&#24847;&#65292;&#23613;&#31649;&#25968;&#32452;&#36807;&#28388;&#22120;&#34987;&#21578;&#35785;&#21482;&#31227;&#38500;&#38750;&#31354;&#20803;&#32032;&#65292;&#38190;2&#65288;&#19968;&#20010;&#31354;&#23383;&#31526;&#20018;&#65289;&#20173;&#28982;&#22312;&#37027;&#37324;&#12290;&#36825;&#26159;&#22240;&#20026;&#21311;&#21517;&#20989;&#25968;&#20801;&#35768;&#38190;2&#65292;&#26080;&#35770;&#20854;&#20540;&#26159;&#20160;&#20040;&#12290;<\/p><h3>&#31227;&#38500;&#29305;&#23450;&#30340;&#31354;&#20540;<\/h3><p>&#22914;&#26524;&#38656;&#35201;&#24494;&#35843;&#35201;&#31227;&#38500;&#30340;&#31354;&#20540;&#65292;&#20363;&#22914;&#21482;&#31227;&#38500;NULL&#20540;&#65292;&#21487;&#20197;&#20256;&#36882;&#19968;&#20010;&#33258;&#23450;&#20041;&#22238;&#35843;&#20989;&#25968;&#12290;<code>array_filter()<\/code>&#22909;&#30340;&#65292;&#35831;&#25552;&#20379;&#38656;&#35201;&#32763;&#35793;&#30340;&#20869;&#23481;&#12290;<\/p><pre><code>&lt;?php\n$array = array(\"apple\", \"\", \"banana\", NULL, \"0\", \"orange\");\n\n$filtered_array = array_filter($array, function($value) {\n    \/\/ Remove only NULL values\n    return !is_null($value);\n});\n\nprint_r($filtered_array);\n\/\/ Output:\n\/\/ Array\n\/\/ (\n\/\/     [0] =&gt; apple\n\/\/     [1] =&gt; \n\/\/     [2] =&gt; banana\n\/\/     [4] =&gt; 0\n\/\/     [5] =&gt; orange\n\/\/ )\n?&gt;<\/code><\/pre><p>&#22312;&#19978;&#36848;&#20363;&#23376;&#20013;&#65292;&#21482;&#26377;NULL&#34987;&#35270;&#20026;&#20026;&#31354;&#24182;&#20174;&#26368;&#32456;&#25968;&#32452;&#20013;&#31227;&#38500;&#12290;<\/p><h2>&#39640;&#32423;&#29992;&#27861;<\/h2><p>&#23545;&#20110;&#26356;&#22797;&#26434;&#30340;&#22330;&#26223;&#65292;&#22914;&#23884;&#22871;&#25968;&#32452;&#25110;&#23545;&#35937;&#23646;&#24615;&#30340;&#25968;&#32452;&#65292;&#21487;&#33021;&#38656;&#35201;&#20351;&#29992;&#33258;&#23450;&#20041;&#20989;&#25968;&#26469;&#22788;&#29702;&#12290;&#25105;&#20204;&#23558;&#36890;&#36807;&#28165;&#29702;&#22810;&#32500;&#25968;&#32452;&#24182;&#22522;&#20110;&#29992;&#25143;&#23450;&#20041;&#30340;&#26631;&#20934;&#36827;&#34892;&#36807;&#28388;&#12290;<\/p><h3>&#22788;&#29702;&#22810;&#32500;&#25968;&#32452;&#30340;&#28165;&#27927;&#24037;&#20316;&#12290;<\/h3><p>&#22788;&#29702;&#22810;&#32500;&#25968;&#32452;&#38656;&#35201;&#36882;&#24402;&#20989;&#25968;&#12290;&#20320;&#21487;&#20197;&#36866;&#24212;&#30340;&#12290;<code>array_filter()<\/code>&#20320;&#38656;&#35201;&#21019;&#24314;&#19968;&#20010;&#33258;&#23450;&#20041;&#20989;&#25968;&#36824;&#26159;&#36882;&#24402;&#35843;&#29992;&#26469;&#24037;&#20316;&#21602;&#65311;<\/p><pre><code>&lt;?php\nfunction array_filter_recursive($input) {\n    foreach ($input as &amp;$value) {\n        if (is_array($value)) {\n            $value = array_filter_recursive($value);\n        }\n    }\n\n    return array_filter($input);\n}\n\n$array = array(\"apple\", array(\"\", \"banana\", NULL), \"orange\");\n\n$clean_array = array_filter_recursive($array);\nprint_r($clean_array);\n\/\/ Output:\n\/\/ Array\n\/\/ (\n\/\/     [0] =&gt; apple\n\/\/     [1] =&gt; Array\n\/\/         (\n\/\/             [1] =&gt; banana\n\/\/         )\n\/\/     [2] =&gt; orange\n\/\/ )\n?&gt;<\/code><\/pre><p>&#36825;&#31181;&#36882;&#24402;&#26041;&#27861;&#30830;&#20445;&#20102;&#25968;&#32452;&#20013;&#30340;&#25152;&#26377;&#23618;&#32423;&#37117;&#34987;&#36807;&#28388;&#12290;<\/p><h3>&#25991;&#26412;&#22238;&#35843;&#36807;&#28388;&#22120;<\/h3><p>&#21478;&#19968;&#31181;&#26356;&#39640;&#32423;&#30340;&#25216;&#26415;&#26159;&#21019;&#24314;&#19968;&#20010;&#22238;&#35843;&#36807;&#28388;&#22120;&#65292;&#35813;&#36807;&#28388;&#22120;&#26681;&#25454;&#26576;&#20123;&#25991;&#26412;&#26631;&#20934;&#31227;&#38500;&#20803;&#32032;&#12290;&#20363;&#22914;&#65292;&#20320;&#21487;&#33021;&#24076;&#26395;&#21024;&#38500;&#25152;&#26377;&#21482;&#21253;&#21547;&#31354;&#30333;&#23383;&#31526;&#30340;&#23383;&#31526;&#20018;&#12290;<\/p><pre><code>&lt;?php\nfunction remove_whitespace_elements($value) {\n    return !preg_match('\/^s*$\/', $value);\n}\n\n$array = array(\"apple\", \" \", \" banana \", \"\", \"  \", \"orange\");\n\n$filtered_array = array_filter($array, 'remove_whitespace_elements');\n\nprint_r($filtered_array);\n\/\/ Output:\n\/\/ Array\n\/\/ (\n\/\/     [0] =&gt; apple\n\/\/     [2] =&gt;  banana \n\/\/     [5] =&gt; orange\n\/\/ )\n?&gt;<\/code><\/pre><p>&#27491;&#21017;&#34920;&#36798;&#24335;&#22312;&hellip;&hellip;<code>remove_whitespace_elements()<\/code>&#35813;&#20989;&#25968;&#26816;&#26597;&#20540;&#26159;&#21542;&#20165;&#30001;&#31354;&#30333;&#23383;&#31526;&#32452;&#25104;&#65292;&#24182;&#20174;&#25968;&#32452;&#20013;&#31227;&#38500;&#36825;&#20123;&#20803;&#32032;&#12290;<\/p><h2>&#32467;&#35770;&#12290;<\/h2><p>&#31227;&#38500;&#25968;&#32452;&#20013;&#30340;&#31354;&#20803;&#32032;&#22312;PHP&#20013;&#21487;&#20197;&#25552;&#39640;&#25968;&#25454;&#22788;&#29702;&#30340;&#36136;&#37327;&#21644;&#21487;&#38752;&#24615;&#12290;&#27491;&#22914;&#26412;&#25351;&#21335;&#25152;&#23637;&#31034;&#30340;&#65292;&#26377;&#35768;&#22810;&#26041;&#27861;&#21644;&#20989;&#25968;&#36866;&#29992;&#20110;&#19981;&#21516;&#30340;&#24773;&#20917;&#21644;&#38656;&#27714;&#12290;&#20351;&#29992;&#36825;&#20123;&#24037;&#20855;&#26102;&#65292;&#35831;&#21153;&#24517;&#32771;&#34385;&#23427;&#20204;&#30340;&#21151;&#33021;&#21644;&#36866;&#29992;&#24615;&#12290;<code>array_filter()<\/code>&#20855;&#26377;&#28789;&#27963;&#24615;&#65292;&#32463;&#24120;&#25552;&#20379;&#24555;&#36895;&#26377;&#25928;&#30340;&#35299;&#20915;&#26041;&#26696;&#12290;&#23545;&#20110;&#26356;&#22797;&#26434;&#30340;&#38656;&#35201;&#65292;&#32534;&#20889;&#33258;&#23450;&#20041;&#20989;&#25968;&#21487;&#20197;&#26356;&#22909;&#22320;&#25511;&#21046;&#20160;&#20040;&#26159;&ldquo;&#31354;&rdquo;&#20803;&#32032;&#12290;&#26080;&#35770;&#24744;&#36873;&#25321;&#21738;&#31181;&#26041;&#27861;&#65292;&#28165;&#29702;&#25968;&#32452;&#26159;&#36808;&#21521;&#26356;&#20581;&#22766;&#21644;&#39640;&#25928;&#30340;PHP&#20195;&#30721;&#30340;&#20851;&#38190;&#27493;&#39588;&#12290;<\/p><\/body>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div><div class=\"wp-block-columns p-0 border is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-columns px-4 py-3 border-bottom has-background is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\" style=\"background:linear-gradient(243deg,rgb(238,238,238) 0%,rgba(58,166,242,0.15) 100%)\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\r\n<figure class=\"wp-block-image size-thumbnail is-resized is-style-rounded is-style-rounded--3\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/xygcfznnzczhsdmwydzhsmzzzmddnq-400x300.jpg\" alt=\"&#38271;&#24037;&#30721;&#22900;1523\" class=\"wp-image-2906\" style=\"object-fit:cover;width:30px;height:30px\"><\/figure>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading my-0\" style=\"font-size:clamp(0.875rem, 0.875rem + ((1vw - 0.2rem) * 0.175), 1rem);\">&#38271;&#24037;&#30721;&#22900;1523<\/h2>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns px-xl-5 px-4 py-xl-4 py-3 is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<p>&#22312;PHP&#20013;&#31227;&#38500;&#25968;&#32452;&#20013;&#30340;&#31354;&#20803;&#32032;&#21487;&#20197;&#20351;&#29992;<code>array_filter()<\/code>&#20989;&#25968;&#32467;&#21512;<code>array_diff()<\/code>&#20989;&#25968;&#26469;&#23454;&#29616;&#12290;&#19979;&#38754;&#25105;&#23558;&#35814;&#32454;&#20171;&#32461;&#36825;&#20010;&#36807;&#31243;&#65306;<\/p>\n<p>&#39318;&#20808;&#65292;&#35753;&#25105;&#20204;&#21019;&#24314;&#19968;&#20010;&#31616;&#21333;&#30340;&#20363;&#23376;&#65292;&#23637;&#31034;&#22914;&#20309;&#23450;&#20041;&#19968;&#20010;&#21253;&#21547;&#31354;&#20803;&#32032;&#30340;&#25968;&#32452;&#65292;&#24182;&#29992;<code>array_filter()<\/code>&#21644;<code>array_diff()<\/code>&#20989;&#25968;&#26469;&#31227;&#38500;&#36825;&#20123;&#31354;&#20803;&#32032;&#12290;<\/p>\n<h3>&#31034;&#20363;&#20195;&#30721;<\/h3>\n<pre><code class=\"language-php\">&lt;?php\n\/\/ &#23450;&#20041;&#19968;&#20010;&#21253;&#21547;&#31354;&#20803;&#32032;&#30340;&#25968;&#32452;\n$emptyArray = ['', 'hello', '', 'world'];\n\n\/\/ &#20351;&#29992; array_filter() &#20989;&#25968;&#31227;&#38500;&#31354;&#20803;&#32032;\n$filteredArray = array_filter($emptyArray, function ($value) {\n    return $value !== '';\n});\n\n\/\/ &#20351;&#29992; array_diff() &#20989;&#25968;&#31227;&#38500;&#31354;&#20803;&#32032;\n$finalArray = array_diff($emptyArray, $filteredArray);\n\necho \"Original Array: \";\nprint_r($emptyArray);\necho \"nFiltered Array: \";\nprint_r($filteredArray);\necho \"nFinal Array: \";\nprint_r($finalArray);\n?&gt;<\/code><\/pre>\n<h3>&#35299;&#37322;<\/h3>\n<ol>\n<li><strong>&#23450;&#20041;&#25968;&#32452;<\/strong>&#65306;&#25105;&#20204;&#39318;&#20808;&#23450;&#20041;&#20102;&#19968;&#20010;&#21517;&#20026; <code>$emptyArray<\/code> &#30340;&#25968;&#32452;&#65292;&#23427;&#21253;&#21547;&#20102;&#22810;&#20010;&#23383;&#31526;&#20018;&#20540;&#65292;&#20854;&#20013;&#19968;&#20123;&#20026;&#31354;&#65288;&#20363;&#22914; <code>''<\/code>&#65289;&#12290;<\/li>\n<li><strong>&#20351;&#29992; array_filter()<\/strong>&#65306;<code>array_filter()<\/code> &#20989;&#25968;&#29992;&#20110;&#36807;&#28388;&#25968;&#32452;&#65292;&#36820;&#22238;&#19968;&#20010;&#26032;&#30340;&#25968;&#32452;&#65292;&#35813;&#25968;&#32452;&#20165;&#21253;&#21547;&#38750;&#31354;&#20803;&#32032;&#12290;&#36825;&#37324;&#25105;&#20204;&#20351;&#29992;&#20102; <code>function<\/code> &#21442;&#25968;&#26469;&#25351;&#23450;&#36807;&#28388;&#35268;&#21017;&#65292;&#21363;&#26816;&#26597;&#27599;&#20010;&#20803;&#32032;&#26159;&#21542;&#19981;&#31561;&#20110;&#31354;&#23383;&#31526;&#20018;&#12290;&#36825;&#20250;&#21435;&#38500;&#25152;&#26377;&#31354;&#20803;&#32032;&#12290;<\/li>\n<li><strong>&#20351;&#29992; array_diff()<\/strong>&#65306;<code>array_diff()<\/code> &#20989;&#25968;&#29992;&#20110;&#21024;&#38500;&#20004;&#20010;&#25968;&#32452;&#20013;&#30340;&#20849;&#21516;&#20803;&#32032;&#65292;&#36825;&#37324;&#30340;&#30446;&#30340;&#26159;&#20445;&#30041;&#21407;&#22987;&#25968;&#32452;&#20013;&#30340;&#25152;&#26377;&#38750;&#31354;&#20803;&#32032;&#65292;&#21516;&#26102;&#21435;&#38500;&#37325;&#22797;&#30340;&#38750;&#31354;&#20803;&#32032;&#12290;&#36825;&#19968;&#27493;&#39588;&#26159;&#36890;&#36807;&#27604;&#36739;&#21407;&#22987;&#25968;&#32452;&#19982;&#36807;&#28388;&#21518;&#30340;&#25968;&#32452;&#26469;&#23436;&#25104;&#30340;&#12290;<\/li>\n<li><strong>&#25171;&#21360;&#32467;&#26524;<\/strong>&#65306;&#26368;&#21518;&#65292;&#25105;&#20204;&#20351;&#29992; <code>print_r()<\/code> &#20989;&#25968;&#25171;&#21360;&#20986;&#22788;&#29702;&#21518;&#30340;&#25968;&#32452;&#65292;&#20197;&#20415;&#26597;&#30475;&#32467;&#26524;&#12290;<\/li>\n<\/ol>\n<p>&#24403;&#20320;&#36816;&#34892;&#19978;&#36848;&#20195;&#30721;&#26102;&#65292;&#20320;&#20250;&#30475;&#21040;&#20197;&#19979;&#36755;&#20986;&#65306;<\/p>\n<pre><code class=\"language-bash\">Original Array: \nArray ( [0] =&gt; '' [1] =&gt; hello [2] =&gt; world )\nFiltered Array: \nArray ( [0] =&gt; hello [1] =&gt; world )\nFinal Array: \nArray ( [0] =&gt; hello [1] =&gt; world )<\/code><\/pre>\n<p>&#20174;&#36755;&#20986;&#32467;&#26524;&#21487;&#20197;&#30475;&#20986;&#65292;&#21407;&#22987;&#25968;&#32452;&#20013;&#30340;&#31354;&#20803;&#32032;&#24050;&#32463;&#34987;&#31227;&#38500;&#20102;&#65292;&#26368;&#32456;&#24471;&#21040;&#30340;&#26159;&#19968;&#20010;&#21482;&#21253;&#21547;&#38750;&#31354;&#20803;&#32032;&#30340;&#26032;&#25968;&#32452;&#12290;<\/p>\n<p>&#36825;&#31181;&#26041;&#27861;&#36866;&#29992;&#20110;&#20219;&#20309;&#38656;&#35201;&#21435;&#38500;&#31354;&#20803;&#32032;&#30340;&#22330;&#26223;&#65292;&#26080;&#35770;&#23427;&#20204;&#26159;&#25968;&#32452;&#36824;&#26159;&#20854;&#20182;&#31867;&#22411;&#30340;&#23481;&#22120;&#25968;&#25454;&#32467;&#26500;&#12290;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Bug&#32534;&#35793;&#29422; &#22312; PHP &#20013;&#65292;&#22914;&#26524;&#20320;&#24819;&#20174;&#25968;&#32452;&#20013;&#31227;&#38500;&#25152;&#26377;&#038;#31354..<\/p>\n","protected":false},"author":1,"featured_media":0,"menu_order":0,"template":"","meta":{"_acf_changed":false},"tags":[],"my1js2nav":[41],"tuisongtax":[],"class_list":["post-570","my1js","type-my1js","status-publish","hentry","my1js2nav-sjjg"],"acf":{"qian_art_seotitle":"","qian_art_seotitle_source":{"label":"SEO\u6807\u9898","type":"text","formatted_value":""},"qian_art_seokws":"","qian_art_seokws_source":{"label":"SEO\u5173\u952e\u8bcd","type":"text","formatted_value":""},"qian_art_stzhong":"","qian_art_stzhong_source":{"label":"\u4e2d | \u77ed\u6807\u9898","type":"text","formatted_value":""}},"_links":{"self":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js\/570","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js"}],"about":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/types\/my1js"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/users\/1"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/media?parent=570"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/tags?post=570"},{"taxonomy":"my1js2nav","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js2nav?post=570"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/tuisongtax?post=570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}