【发布时间】:2026-01-01 03:50:02
【问题描述】:
我 我试图从数组列表中删除 null 或空值,但没有工作。
以下是我的数组输出..
Array
(
[0] => Array
(
[post_id] => 1173
[post_content] => Rocking Tips
[comment_id] => 1173
[comment_content] => Nice Post
[comment_date] =>
[user_id] =>
[username] =>
[email] =>
[first_name] =>
[last_name] =>
)
[1] => Array
(
[post_id] =>
[post_content] =>
[comment_id] =>
[comment_content] =>
[comment_date] =>
[user_id] =>
[username] =>
[email] =>
[first_name] =>
[last_name] =>
)
[2] => Array
(
[post_id] => 1173
[post_content] => Rocking Tips
[comment_id] => 1176
[comment_content] => WOnder
[comment_date] => 2020-05-21 21:10:04
[user_id] => 168
[username] => kkkk20
[email] => fdfsfsf@gmail.com
[first_name] => sam
[last_name] => test
[reply] => Array
(
[comment_id] => 1177
[comment_details] => Thank YOu
[comment_date] => 2020-05-21 21:12:14
[user_id] => 179
[username] => test20201
[email] => fdfdfd@gmail.com
[replay] =>
)
)
)
我尝试使用 array_filter() 删除空数组值,但当我打印数组时仍然显示空值。
我也试过了,
$filtered = array_filter($myArray, function($var){return !is_null($var);} );
echo "<pre>List Data";print_r($filtered);
我想从列表中删除1 索引数组
【问题讨论】:
标签: php arrays array-filter