How does PHP determine whether a multi-dimensional array contains null values! For example, if a column has a null value, this column is excluded. how can this problem be solved?
Reply to discussion (solution)
So ??
$ Arr = array ('listid' => array ('', 5), 'title' => array ('', 38 ), 'type' => array ('', 'I'), 'count' => array ('', 3), 'content' => array ('none ', 'none'); foreach ($ arr as $ k => $ v) {if (is_array ($ v) {foreach ($ v as $ v2) {if ($ v2 = '') {unset ($ arr [$ k]) ;}}} echo"";print_r($arr);echo "
";/* Array ([content] => Array ([0] => None [1] => None ))*/
I think what you mean is not answered on the second floor. your data structure seems to be an article. Is it true that a few articles remove all the first data and leave only the second key value for each one?
In the foreach loop array, the row = null is first found to be null, and then unset
The third floor is what I want to express. in the above example! The second key value is retained, because all values are available. how can this problem be solved?
We recommend that you paste your array and final result. And describe how it works.
Print _ ($ _ POST );
Result:
Array
(
[Listid] => Array
(
[0] => 1
[1] => 5
[2] => 4
)
[Title] => Array
(
[0] =>
[1] => 33
[2] => 39
)
[Type] => Array
(
[0] => u
[1] => t
[2] =>
)
[Count] => Array
(
[0] =>
[1] => 7
[2] =>
)
[Content] => Array
(
[0] => None
[1] => None
[2] => None
)
)
$ Arr = array ('listid' => array ('', 5), 'title' => array ('', 38 ), 'type' => array ('', 'I'), 'count' => array ('', 3), 'content' => array ('none ', 'none'),); $ t = call_user_func_array ('Array _ map', array_merge (array (null), $ arr )); foreach ($ t as $ k => $ v) if (array_diff ($ v, array (''))! = $ V) unset ($ t [$ k]); $ t = count ($ t) = 1? Array_chunk (current ($ t), 1): call_user_func_array ('Array _ map', array_merge (array (null), $ t )); print_r (array_combine (array_keys ($ arr), $ t ));
Array ([listid] => Array ([0] => 5) [title] => Array ([0] => 38) [type] => Array ([0] => I have) [count] => Array ([0] => 3) [content] => Array ([0] => None ))
Thank you! You have obtained the desired result.
Now, if $ arr does not have a complete set of values, an error will occur.
Thank you for solving the problem.