HELP!! - I have a PHP porblem
-
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"
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 -
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' Roseswhere 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"
-
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"
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 -
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' Rosesi 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"
-
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"
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 theelse
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 -
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 theelse
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' Rosesoh, 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"
-
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 theelse
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' Rosesim 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"
-
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"
[^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 -
[^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' Rosesbelow 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"
-
[^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' Rosesi 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"