Jump to content

Still not quite understanding multidimensional arrays...


mkosmosports

Recommended Posts

Still not getting the clear picture.
Array
(
    [Arsenal] => Array
        (
            [teamid] => 1
            [fullname] => Arsenal London
            [linkable] => y
            [sdate] => 05
            [edate] =>
        )

    [Aston Villa] => Array
        (
            [teamid] => 2
            [fullname] => Aston Villa
            [linkable] => y
            [sdate] => 05
            [edate] =>
        )
)

Out of this md array. How can I loop through and pull out the the second level id (ex. Aston Villa) where [sdate] = 05 for example. I just cant seem to get it right..

Any help appreciated.
Marek
you would want to do something like this... I'll join the bandwagon and assume your master array is called $foo

[code=php:0]
$matchingFullnames = array(); // Make an array to hold our names

foreach($foo as $item) { // Loop through foo
    if($item['sdate'] == 05) {
          $matchingFullnames[] = $item['fullname']; // Add the fullname to our array
    }
}

print_r($matchingFullnames); // It will display the two entries since both of their sdates are 05
[/code]

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.