Help! For example, if a column appears empty once, exclude this column, how to implement
Reply to discussion (solution)
Is that so??
$arr =array (' Listid ' =>array (', 5 '), ' title ' =>array (', ', '), ' type ' =>array (' ', ' I have '), ' Count ' =>array (', 3) , ' content ' =>array (' none ', ' none '), foreach ($arr as $k + $v) {if (Is_array ($v)) {foreach ($v as $v 2) {if ($v 2== ") {unset ($ arr[$k]);}}} echo "";p Rint_r ($arr); echo"
/*array ( [content] = = Array ( [0] = = None [1] = none )) */
I don't think you mean 2 floor. Answer, your data structure is a like the article is a few articles is not all the first data is removed only left each of the second key value of a
A foreach loop array, which finds that the null value first =null the line and then unset out
3 floor is what I want to express, in the above example! is to keep the second key value, because it all has a value, how to do it?
It is recommended to post your array and the final result. and explain the principle.
Print_ ($_post);
Results:
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 (', ', ') ', ' type ' = = Array (' , ' I have '), ' 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 = Cou NT ($t) = = 1? Array_chunk (current ($t), 1): Call_user_func_array (' Array_map ', Array_merge (array (null), $t));p Rint_r (array_combine (Array_keys ($arr), $t));
Array ([ Listid] + = Array ( [0] = 5 ) [title] = = Array ( [0] = ) [Type] = = Array ( [0] = = I have ) [count] /= Array ( [0] = 3 ) [content] = = Array ( [0] = = none ))
Thank you for the moderator answer! You've got the results you want.
Now, if there is not a complete set of values in the $arr, there will be an error.
Thank you, it's settled.