我的数组具有以下结构。它是通过表单提交的文件数组。我有多个表单输入字段。但是,如果用户将某些字段留空,则数组将如下所示。然后我将它写入我的数据库。我不想写空字段。
我尝试使用array_filter()
函数,但由于我的数组不是完全空的,所以它不起作用。错误元素设置为4
。我该怎么做?
Array
(
[0] => Array
(
[name] => stock-photo-cup-icons-tea-and-coffee-raster-version-109119257.jpg
[type] => image/jpeg
[tmp_name] => /tmp/phpqWWM9X
[error] => 0
[size] => 30609
)
[1] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[2] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[3] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
)