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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jan 2006
    Posts
    568
    Thanks
    6
    Thanked 84 Times in 84 Posts

    php arrays with same value

    i have an array, eg
    Code:
    $arr[0]="banana";
    $arr[1]="apple";
    $arr[2]="banana";
    $arr[3]="banana";
    $arr[4]="pineapple";
    and i need to find out how many different values there are (3 in the above case), and then list them on a page. How would I go about this?
    tia for any suggestions!
    gus
    Last edited by gusblake; 11-03-2006 at 12:57 AM. Reason: typo

  • #2
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    866
    Thanks
    7
    Thanked 30 Times in 29 Posts
    There is a php function that should do the trick

    $unique = array_unique ( $original )

    click here to read more about this function from php.net

    I hope that helps..

    All the best


  •  

    Posting Permissions

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