Results 1 to 5 of 5

Thread: [RESOLVED] Word within string?

  1. #1

    Thread Starter
    Addicted Member _Yoyo's Avatar
    Join Date
    Apr 2001
    Location
    Dominican Republic
    Posts
    187

    Resolved [RESOLVED] Word within string?

    HI

    How do I know if the word 'position' is within this string? is there an internal function to do this?

    dsgsgdñlkjslkgjlfñjgpositionfdsñlkfñkldsf
    The biggest man you ever did see was once just a baby.

    Bob Marley

  2. #2
    Lively Member {yak}'s Avatar
    Join Date
    Aug 2005
    Posts
    119

    Re: Word within string?

    Yes, take a look at str_pos()
    Good luck
    {yak}

  3. #3
    Hyperactive Member
    Join Date
    Nov 2003
    Location
    In Front of my computer...
    Posts
    367

    Re: Word within string?

    stristr

    <?php
    $string = 'Hello World!';
    if(stristr($string, 'earth') === FALSE) {
    echo '"earth" not found in string';
    }
    // outputs: "earth" not found in string
    ?>
    Born to help others
    (If I've been helpful then please rate my post. Thanks)

    call me EJ or be slapped!

  4. #4

    Thread Starter
    Addicted Member _Yoyo's Avatar
    Join Date
    Apr 2001
    Location
    Dominican Republic
    Posts
    187

    Re: Word within string?

    Thanks!
    The biggest man you ever did see was once just a baby.

    Bob Marley

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [RESOLVED] Word within string?

    For simply checking the presence of a substring within a string, strpos should be preferred over strstr and its variants because the former merely returns a position and the latter return the actual substring. strpos is thus more efficient.

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