Jump to content

Recommended Posts

Ive got this multidimensional array:
Array
(
    [200701] => Array
        (
            [0] => France
            [1] => Serbia
        )

    [200611] => Array
        (
            [0] => Italy
            [1] => Italy
            [2] => England
            [3] => England
        )

    [200610] => Array
        (
            [0] => England
            [1] => England
        )
)

Im interested in doing three things with it:
1. Get the Max year/month value, so 200701.
2. Clean up the array to avoid duplicates in the subarray.

Any ideas?

Many thanks!
Link to comment
https://forums.phpfreaks.com/topic/36079-still-problems-with-arrays/
Share on other sites

Damn, I hate being persistent and annoying but is this really impossible?? I mean, there is gotta be a way to somehow retrieve the highest value of the ID in an associative array and then being able to use it...

I promise Ill help people out when I gain enough knowledge... :P
Yeah, thats the problem though, the ids of each 1st level array are not numeric, so sorting them will not make 0 the first id. They are dates, like 200701, 200611, etc.
Array
(
    [200701] => Array
        (
            [1] => France
        )
    [200611] => Array
        (
            [1] => Italy
            [2] => England
        )
    [200610] => Array
        (
            [1] => England
        )
)
So now what I want to do is somehow pull the 200701 out of this md array, and use it in a variable later on.
Thanks Jesirose! That loop does it. The query I had was ordered already so I didnt need to make use of ksort. Another array question for y'all. Can I merge/combine two arrays together (ok, I know I can use array_merge, but....), WHILE throwing out any duplicates so I come out with an array only containing all unique values in the other two arrays combined...

Thanks...
Damnit, I still cant get a certain syntax right. The following md array:
Array
(
    [Griffin] => Array
        (
            [0] => Peter
            [1] => Lois
            [2] => Megan
            [3] => Glenn
        )

    [Quagmire] => Array
        (
            [0] => Glenn
        )

    [Brown] => Array
        (
            [0] => Cleveland
            [1] => Loretta
            [2] => Junior
        )

)
How can I get all the last names(1st level array id's) when the first name (2nd level array) is Glenn?

Thanks!
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.