Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    187
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Finding unique values in multidimensional arrays

    say i have the following:


    PHP Code:
    $contact["bob"][1] = "0125"
    $contact["bob"][2] = "5442"
    $contact["bob"][3] = "4254"
    $contact["eric"][1] = "2562"
    $contact["eric"][2] = "1423"
    $contact["eric"][3] = "1455"
    $contact["fred"][1] = "1562"
    $contact["fred"][2] = "0234"
    $contact["fred"][3] = "2234"
    $contact["dick"][1] = "0114"
    $contact["dick"][2] = "8845"
    $contact["dick"][3] = "1455" 
    how would i create a function that would look through each array and find the different values, in $contact[][3] ?

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    PHP Code:
    foreach ($contact as $key => $value){
    $newarray[] = $value[3];
    }

    $newarray array_unique($newarray); 

  • Users who have thanked Mwnciau for this post:

    phill_ridout (08-28-2007)

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    187
    Thanks
    5
    Thanked 0 Times in 0 Posts
    sorted, thanks for that


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •