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
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.