I’m really stuck here. Im having an array looking like this below.
And now I would like to count postStatus where postStatus = 0, for all of the arrays.
So in this case there would be 2. But how do I do this?
Array
(
[1] => Array
(
[postId] => 1
[postHeader] => Post-besked #1
[postContent] => Post content #1
[postDate] => 2011-12-27 17:33:11
[postStatus] => 0
)
[2] => Array
(
[postId] => 2
[postHeader] => Post-besked #2
[postContent] => POst content #2
[postDate] => 2011-12-27 17:33:36
[postStatus] => 0
)
)
Just loop the outer array, check if there is a postStatus, increment a value to keep that count and you’re done…
EDIT:
I forgot to mention that isset() can be used but a better pratice is to use array_key_exists because if $myarraycontent[‘postStatus’] is NULL, it will return false. Thats the way isset() works…