php quik question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alex79
    Confirmed User
    • Jun 2002
    • 996

    #1

    php quik question

    what is the function with wich i can see if a string is in other string?
  • nibbi
    Confirmed User
    • Sep 2002
    • 104

    #2
    You can use substr_count() to count the number of times a given string is found within another.

    http://us4.php.net/manual/en/function.substr-count.php
    http://www.xRag.com

    Comment

    • jennycards
      Confirmed User
      • Feb 2002
      • 1124

      #3
      ereg(), eregi()
      Make Money with true niche programs like Adult ECards - Pantyhose Fetish - Men in Pantyhose

      Comment

      • Ash@phpFX
        Confirmed User
        • Nov 2003
        • 4292

        #4
        or preg_match()

        Comment

        • natkejs
          Confirmed User
          • Jan 2003
          • 1640

          #5
          strstr($string, "string")

          find the first occurance of "string" in $string ... this command is pretty useful.

          in your case...

          if (strstr($string, "UHH")) { echo "YES.. UHH is in string!" }

          Comment

          • alex79
            Confirmed User
            • Jun 2002
            • 996

            #6
            thanks for your reply

            i want to make an redirect to another page if a string is in the referer page...i've tryed eregi() and strstr() and both times i get same error

            this is the code i used:
            PHP Code:
            <?
            if (strstr($_SERVER['HTTP_REFERER'], "amateur"))
            { header("location: [url]http://www.mydomain.com/amateur.html[/url]"); die();}
            ?>
            and this is the error i get when i come to this page from another page which the "amateur" in the url:


            "Cannot add header information - headers already sent by (output started at /home/..............) "

            any ideea why i get this error?

            Comment

            • natkejs
              Confirmed User
              • Jan 2003
              • 1640

              #7
              ehm you shouldn't include any html tags there, make it like this.
              edit: nevermind this, it's VBulletin adding the html tags even when outputing PHP code.

              PHP Code:
              <?
              if (strstr($_SERVER['HTTP_REFERER'], "amateur")) { header("Location: http://www.mydomain.com/amateur.html"); };
              ?>
              also any output command such as echo/print being executed before your re-direct will cause it to fail. so make sure there is nothing in your script that outputs info before it's supposed to re-direct.

              Comment

              • sweet7
                Confirmed User
                • May 2003
                • 1792

                #8
                Originally posted by asher
                or preg_match()
                ICQ: 282814268

                Comment

                • Chris
                  Too lazy to set a custom title
                  • May 2003
                  • 27880

                  #9
                  feel free to use my code
                  php.hahahahahahahaha%%#)I$)#.PHP!

                  that should take care of ya

                  cheers
                  [email protected]

                  Comment

                  Working...