www.webdeveloper.com
Results 1 to 3 of 3

Thread: Return if string is in an array

  1. #1
    Join Date
    Dec 2006
    Posts
    46

    Return if string is in an array

    Hey I need a simple function to determine if a given string is contained in an array

    For Instance:
    $findInMe = Array('SOLD OUT', 'ERROR', 'EXPIRED', 'NO DEAL');
    $givenString = somethingFromMyDatabase;

    If $givenString was found in $findInMe then the function would return true

    Anybody know how to do this?

    Thanks,
    I appreciate it!

  2. #2
    Join Date
    Sep 2006
    Location
    Europe
    Posts
    174
    PHP has just the function - in_array($needle, array $haystack) @ http://www.php.net/in_array

  3. #3
    Join Date
    Dec 2006
    Posts
    46
    thats was ridiculously simple, thanks!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles