I want to be able to check if a certain key exists within my array. I have an array and I’m merging multiple arrays from mysql. What would be the best way to do so?
for example
Array
(
[0] => Array
(
[id] => 3
[comments] => comment text
)
[1] => Array
(
[id] => 3
[comments] => comment text
)
[2] => Array
(
[idMenu] => 1
[names] => text
)
[3] => Array
(
[idMenu] => 3
[names] => names text
)
)
So I’m trying to see if this array has comments and/or names.
do i have to do an if statement?
Thanks
Assuming that your parent array will always return bunch of children arrays…
Now, that merely checks to see if the parent has a child array with one of those keys.. Actually checking the value to see if it is empty would take a little more code, but this should get you going in the right direction.