help with strpos

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yawnmoth

    help with strpos

    say i have the following php script:

    <?
    if (!is_int(strpos ("a","aaa")) )
    // if (strpos("a","aa a") === false)
    print "no match";
    else print "match";
    ?>

    when i run it, i am told there is no match, when there actually is.
    it doesn't matter which if statement i use (the uncommented out one,
    or the commented out one) - i get the same thing. further, if i
    change "aaa" to "xxx", it doesn't, all of a sudden, say "match"
    (indicating that i would just need to swap the statements) - it
    *still* says no match.

    so, any ideas as to what's wrong with my code? any help would be
    appreciated - thanks :)
  • Jan Pieter Kunst

    #2
    Re: help with strpos

    In article <a0d63404.04041 71647.6bbf3ce8@ posting.google. com>,
    terra1024@yahoo .com (yawnmoth) wrote:
    [color=blue]
    > say i have the following php script:
    >
    > <?
    > if (!is_int(strpos ("a","aaa")) )
    > // if (strpos("a","aa a") === false)
    > print "no match";
    > else print "match";
    > ?>
    >
    > when i run it, i am told there is no match, when there actually is.[/color]

    It should be:

    strpos('aaa','a ')

    int strpos ( string haystack, string needle [, int offset])

    <http://nl.php.net/strpos>

    JP

    --
    Sorry, <devnull@cauce. org> is een "spam trap".
    E-mail adres is <jpk"at"akamail .com>, waarbij "at" = @.

    Comment

    • yawnmoth

      #3
      Re: help with strpos

      Jan Pieter Kunst <devnull@cauce. org> wrote in message news:<devnull-D21325.06550518 042004@news1.ne ws.xs4all.nl>.. .[color=blue]
      ><snip>
      >
      > It should be:
      >
      > strpos('aaa','a ')
      >
      > int strpos ( string haystack, string needle [, int offset])
      >
      > <http://nl.php.net/strpos>
      >
      > JP[/color]

      i can't believe i did that, heh. ah well - thanks :)

      Comment

      Working...