51 users online (0 members and 51 guests)  


  Results 1 to 2 of 2

Related

  1. some php questions    Forum: PHP Forum
    Replies: 0
  2. 3 questions    Forum: CGI Perl Forum
    Replies: 2
  3. How to do this in CSS? A few questions.    Forum: CSS Forum
    Replies: 0
  4. Six Questions    Forum: HTML Forum
    Replies: 4
  5. Questions...    Forum: HTML Forum
    Replies: 1
  1. #1
    jonys's Avatar
    Disabled

    Status
    Offline
    Join Date
    Feb 2009
    Posts
    8

    some php questions

    okay, in the past week i bought a book about php and mysql (php and mysql for dummies),

    and it explains how to check information.

    but it only tell's me how to don't accept full words. but what i want to know is how to check for parts of words.

    for example: the word is: pineapple
    the book tells me how to look for the whole word: pineapple.
    but i want to be able to scearch for only the part: pine or apple.

    can someone tell me how to do that?

  2. #2
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: some php questions

    You are looking for the function strpos.

    Code:
    $haystack = "pineapple";
    $needle = "pine";
    $loc = strpos($haystack, $needle);
    if ($loc >= 0) {   // Needs to include 0 in case $needle is found at the beginning of $haystack
    echo "Success";
    } else {
    echo "Failure";
    }
    A HUGE resource in addition to your book is php.net. Every function is there with a description, examples, and user recommendations. Look through there. You will find quite a bit of helpful information.



Tags for this Thread