Jump to content

Count for specific in array


aquadeluxe

Recommended Posts

I have an array that looks like this

Array
(
    [codelist] => Array
        (
            [name] => Kodewerx Codes
            [game] => Array
                (
                    [name] => Koderwerx Super Mario 64 DS
                    [gameid] => ASME f486f859
                    [date] => 1979/11/30 00:00
                    [cheat] => Array
                        (
                            [0] => Array
                                (
                                    [name] => asdfadsf
                                    [code] =>  5465465 6546546
                                    [note] => asdfadsf
                                )

                            [1] => Array
                                (
                                    [name] => wertertueyu
                                    [code] =>  87846854 4654987
                                    [note] => adfghhtrh
                                )

                        )

                )

        )

)

I need something that will count how many different ['codelist']['game'] there are.[/code][/code]

Link to comment
https://forums.phpfreaks.com/topic/102024-count-for-specific-in-array/
Share on other sites

I don't know off the top of my head of a PHP function that will do that for you. So you will have to write that for your self.

It should be someting like this

<?php
$counter = 0;
foreach( $array_that_contains_codelists as $codelist )
{
  if (isset($codelist['game']))
  {
    $counter++;
   }
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.