Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Back Room
  4. HELP!! - I have a PHP porblem

HELP!! - I have a PHP porblem

Scheduled Pinned Locked Moved The Back Room
phpcomhelp
11 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Nnamdi Onyeyiri

    I am trying to remove all of the special characters, like £$%^ and so on from a string, but everthing i have tried does not work. plz help, ive pent ages on this now.:(( :mad: :((


    :bob: Email: theeclypse@hotmail.com   URL: http://www.onyeyiri.co.uk:bob:

    "What goes up must come down. Ask any system administrator"

    J Offline
    J Offline
    Jeremy Falcon
    wrote on last edited by
    #2

    if(eregi("[^a-z0-9 .,:;!?]+", $data, $array))
    {
    for($x=1; $x<count($array); $x++)
    {
    if(trim($array[x]) != "") $newstring += $array[x];
    }
    }

    The bill is in the mail. :) Jeremy L. Falcon Homepage : Sonork = 100.16311
    "But everybody darlin' sometimes bites the hand that feeds." "Remember in this game we call life that no one said it's fair." "Just because you're winnin' don't mean you're the lucky ones." Song: Breakdown - Album: Use Your Illusion II - Artist: Guns N' Roses

    N 1 Reply Last reply
    0
    • J Jeremy Falcon

      if(eregi("[^a-z0-9 .,:;!?]+", $data, $array))
      {
      for($x=1; $x<count($array); $x++)
      {
      if(trim($array[x]) != "") $newstring += $array[x];
      }
      }

      The bill is in the mail. :) Jeremy L. Falcon Homepage : Sonork = 100.16311
      "But everybody darlin' sometimes bites the hand that feeds." "Remember in this game we call life that no one said it's fair." "Just because you're winnin' don't mean you're the lucky ones." Song: Breakdown - Album: Use Your Illusion II - Artist: Guns N' Roses

      N Offline
      N Offline
      Nnamdi Onyeyiri
      wrote on last edited by
      #3

      where did $array come from?


      :bob: Email: theeclypse@hotmail.com   URL: http://www.onyeyiri.co.uk:bob:

      "What goes up must come down. Ask any system administrator"

      J 1 Reply Last reply
      0
      • N Nnamdi Onyeyiri

        where did $array come from?


        :bob: Email: theeclypse@hotmail.com   URL: http://www.onyeyiri.co.uk:bob:

        "What goes up must come down. Ask any system administrator"

        J Offline
        J Offline
        Jeremy Falcon
        wrote on last edited by
        #4

        Heaven! ;) Just declare a new array and eregi() will populate it for you. Jeremy L. Falcon Homepage : Sonork = 100.16311
        "But everybody darlin' sometimes bites the hand that feeds." "Remember in this game we call life that no one said it's fair." "Just because you're winnin' don't mean you're the lucky ones." Song: Breakdown - Album: Use Your Illusion II - Artist: Guns N' Roses

        N 1 Reply Last reply
        0
        • J Jeremy Falcon

          Heaven! ;) Just declare a new array and eregi() will populate it for you. Jeremy L. Falcon Homepage : Sonork = 100.16311
          "But everybody darlin' sometimes bites the hand that feeds." "Remember in this game we call life that no one said it's fair." "Just because you're winnin' don't mean you're the lucky ones." Song: Breakdown - Album: Use Your Illusion II - Artist: Guns N' Roses

          N Offline
          N Offline
          Nnamdi Onyeyiri
          wrote on last edited by
          #5

          i use that code, but when it tries to remove the ! from cr!ap, it does not display anything. I used echo $newstring, but nothing appeared.


          :bob: Email: theeclypse@hotmail.com   URL: http://www.onyeyiri.co.uk:bob:

          "What goes up must come down. Ask any system administrator"

          J 1 Reply Last reply
          0
          • N Nnamdi Onyeyiri

            i use that code, but when it tries to remove the ! from cr!ap, it does not display anything. I used echo $newstring, but nothing appeared.


            :bob: Email: theeclypse@hotmail.com   URL: http://www.onyeyiri.co.uk:bob:

            "What goes up must come down. Ask any system administrator"

            J Offline
            J Offline
            Jeremy Falcon
            wrote on last edited by
            #6

            That's because ! is valid according to the regular expression.

            [^a-z0-9 .,:;!?]+

            If there are no matches (like in this case) eregi() will return false and $newstring never has a value set. You can use the else clause if you want to set a flag or something saying the data is good, set $newstring to $data, or whatever. What chars do you want to keep? For just alphanumeric with spaces, try this...

            [^a-z0-9 ]+

            Jeremy L. Falcon Homepage : Sonork = 100.16311
            "But everybody darlin' sometimes bites the hand that feeds." "Remember in this game we call life that no one said it's fair." "Just because you're winnin' don't mean you're the lucky ones." Song: Breakdown - Album: Use Your Illusion II - Artist: Guns N' Roses

            N 2 Replies Last reply
            0
            • J Jeremy Falcon

              That's because ! is valid according to the regular expression.

              [^a-z0-9 .,:;!?]+

              If there are no matches (like in this case) eregi() will return false and $newstring never has a value set. You can use the else clause if you want to set a flag or something saying the data is good, set $newstring to $data, or whatever. What chars do you want to keep? For just alphanumeric with spaces, try this...

              [^a-z0-9 ]+

              Jeremy L. Falcon Homepage : Sonork = 100.16311
              "But everybody darlin' sometimes bites the hand that feeds." "Remember in this game we call life that no one said it's fair." "Just because you're winnin' don't mean you're the lucky ones." Song: Breakdown - Album: Use Your Illusion II - Artist: Guns N' Roses

              N Offline
              N Offline
              Nnamdi Onyeyiri
              wrote on last edited by
              #7

              oh, now i understand it. before i never understood that stuff that you put in the ergeg function


              :bob: Email: theeclypse@hotmail.com   URL: http://www.onyeyiri.co.uk:bob:

              "What goes up must come down. Ask any system administrator"

              1 Reply Last reply
              0
              • J Jeremy Falcon

                That's because ! is valid according to the regular expression.

                [^a-z0-9 .,:;!?]+

                If there are no matches (like in this case) eregi() will return false and $newstring never has a value set. You can use the else clause if you want to set a flag or something saying the data is good, set $newstring to $data, or whatever. What chars do you want to keep? For just alphanumeric with spaces, try this...

                [^a-z0-9 ]+

                Jeremy L. Falcon Homepage : Sonork = 100.16311
                "But everybody darlin' sometimes bites the hand that feeds." "Remember in this game we call life that no one said it's fair." "Just because you're winnin' don't mean you're the lucky ones." Song: Breakdown - Album: Use Your Illusion II - Artist: Guns N' Roses

                N Offline
                N Offline
                Nnamdi Onyeyiri
                wrote on last edited by
                #8

                im still not 100% sure thou, i just want letters, nothin else, what would i use.


                :bob: Email: theeclypse@hotmail.com   URL: http://www.onyeyiri.co.uk:bob:

                "What goes up must come down. Ask any system administrator"

                J 1 Reply Last reply
                0
                • N Nnamdi Onyeyiri

                  im still not 100% sure thou, i just want letters, nothin else, what would i use.


                  :bob: Email: theeclypse@hotmail.com   URL: http://www.onyeyiri.co.uk:bob:

                  "What goes up must come down. Ask any system administrator"

                  J Offline
                  J Offline
                  Jeremy Falcon
                  wrote on last edited by
                  #9

                  [^a-z]+

                  Jeremy L. Falcon Homepage : Sonork = 100.16311
                  "But everybody darlin' sometimes bites the hand that feeds." "Remember in this game we call life that no one said it's fair." "Just because you're winnin' don't mean you're the lucky ones." Song: Breakdown - Album: Use Your Illusion II - Artist: Guns N' Roses

                  N 2 Replies Last reply
                  0
                  • J Jeremy Falcon

                    [^a-z]+

                    Jeremy L. Falcon Homepage : Sonork = 100.16311
                    "But everybody darlin' sometimes bites the hand that feeds." "Remember in this game we call life that no one said it's fair." "Just because you're winnin' don't mean you're the lucky ones." Song: Breakdown - Album: Use Your Illusion II - Artist: Guns N' Roses

                    N Offline
                    N Offline
                    Nnamdi Onyeyiri
                    wrote on last edited by
                    #10

                    below is the code i am using, but nothing is outputed by the echo.

                    $array = array();
                    if(eregi("[^a-z]+", $the_msg, $array))
                    {
                    for($x=1; $x


                    :bob: Email: theeclypse@hotmail.com   URL: http://www.onyeyiri.co.uk:bob:

                    "What goes up must come down. Ask any system administrator"

                    1 Reply Last reply
                    0
                    • J Jeremy Falcon

                      [^a-z]+

                      Jeremy L. Falcon Homepage : Sonork = 100.16311
                      "But everybody darlin' sometimes bites the hand that feeds." "Remember in this game we call life that no one said it's fair." "Just because you're winnin' don't mean you're the lucky ones." Song: Breakdown - Album: Use Your Illusion II - Artist: Guns N' Roses

                      N Offline
                      N Offline
                      Nnamdi Onyeyiri
                      wrote on last edited by
                      #11

                      i worked it out, i use the eregi_replace function, with [^a-z]+ as the pattern.


                      :bob: Email: theeclypse@hotmail.com   URL: http://www.onyeyiri.co.uk:bob:

                      "What goes up must come down. Ask any system administrator"

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups