How can I validate the multidimensional array.My array is like
Array
(
[level] => Array
(
[1] => 1
[2] => 2
)
[subject] => Array
(
[1] => Array
(
[0] => 4
[1] => 9
)
[2] => Array
(
[0] => 4
)
)
)
I want to check the keys for [level] is in [subject]. Please help me. How it is possible.
if (count(array_intersect_key($array['level'], $array['subject'])) !=
count($array['level'])) {
echo 'level and subject have different keys';
}
If I understood:
array_diff_key($myArray['level']), $myArray['subject']);
sample: http://codepad.org/i00KNhDJ
Order is important:
array_diff_key($myArray['level']), $myArray['subject']) !== array_diff_key($myArray['subject']), $myArray['level']);