SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2004
    Location
    Temecula, CA
    Posts
    188
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    stripos and strpos boolean

    How do I get this to work
    PHP Code:
    if (stripos($HayStack$Needle))
    {


    when $Needle is the first part of $HayStack? Both stripos and strpos return 0 in this case, which if interprets as false. The manual warns against this, but I couldn't find a clear solution to the problem there.

    And I did try
    PHP Code:
    if (stripos($HayStack$Needle) === true
    and
    PHP Code:
    if (stripos($HayStack$Needle) != false
    but they didn't work either.

    Any ideas?

  2. #2
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,561
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if (stripos($HayStack, $Needle) !== false)

  3. #3
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if ( stripos($HayStack$Needle) && substr$HayStack0len($Needle) == $Needle ) )
    {


    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  4. #4
    SitePoint Zealot
    Join Date
    Jan 2004
    Location
    Temecula, CA
    Posts
    188
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by byron3@earthlink View Post
    PHP Code:
    if ( stripos($HayStack$Needle) && substr$HayStack0len($Needle) == $Needle ) )
    {


    I didn't get this to work, but I did get this to:
    PHP Code:
     if ( stripos($HayStack$Needle) || substr$HayStack0strlen($Needle)) == $Needle  
    Thanks for the help. I wouldn't have thought of it.


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
  •