Results 1 to 2 of 2

Thread: Array find value

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Location
    Osaka
    Posts
    200

    Array find value

    Is it possible to find index of array where values is "any value" ?

    Suppose there is array from index 0 to 99 and have same values stored 0 to 99.

    And we want to find the index of array where value is "35".

    I need some fast solution otherwise it can done thru for loop.

  2. #2
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527

    Re: Array find value

    PHP Code:
    <?php
    $array 
    = array(=> 'blue'=> 'red'=> 'green'=> 'red');

    $key array_search('green'$array); // $key = 2;
    $key array_search('red'$array);  // $key = 1;
    ?>

Posting Permissions

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



Click Here to Expand Forum to Full Width