PHP - Counting matching arrays in array

Posted by Sergio on Stack Overflow See other posts from Stack Overflow or by Sergio
Published on 2010-04-18T16:33:44Z Indexed on 2010/04/18 16:43 UTC
Read the original article Hit count: 417

Filed under:
|

hi there,

I have an array structure that looks like this:

    Array
(
    [0] => Array
        (
            [type] => image
            [data] => Array
                (
                    [id] => 1
                    [alias] => test
                    [caption] => no caption
                    [width] => 200
                    [height] => 200
                )

        )

    [1] => Array
        (
            [type] => image
            [data] => Array
                (
                    [id] => 2
                    [alias] => test2
                    [caption] => hello there
                    [width] => 150
                    [height] => 150
                )

        )

)

My question is, how can I get a count of the number of embedded arrays that have their type set as image (or anything else for that matter)? In practise this value can vary.

So, the above array would give me an answer of 2.

Thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about array