SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Help

  1. #1
    SitePoint Zealot imagize's Avatar
    Join Date
    Oct 2004
    Location
    Australia
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help

    Say i have this (basic)

    $str = 'hello';

    is there somehow i can go..

    if ($str contains a o)
    {
    do this
    }

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if(strpos($str'o') !== FALSE){
        
    //do whatever


  3. #3
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try:
    PHP Code:
    $str 'hello';
    if(
    stristr($str'o')) {
        echo 
    '"' $str ,'" contains a "o"';

    See stristr().

    -Helge

    Edit:

    Mark beat me to it. Either str(i)pos or str(i)str will do the trick.

  4. #4
    SitePoint Zealot imagize's Avatar
    Join Date
    Oct 2004
    Location
    Australia
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Alot


Bookmarks

Posting Permissions

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