{}[]()<> and anyother that are specified are bad!!!
Moderator: General Moderators
{}[]()<> and anyother that are specified are bad!!!
Hello, I'm trying to, in one of my scripts, take a string/value from a $_POST super and post is to the database without the <>(){}[] characters included in it. If there is any function that checks the contents of a specified string and you can erase or bring a value of ture or false so that way I can do an if...else statement with it then I'd really love to know these kind of things.
If anyone has some kind of way of accomplishing this then that'll be great!
Thanks and all help is appreciated.
- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York
Code: Select all
<?
$codetoreplace = "y<o>(fff)yy{ggg}[ffff]"; // string with invalid characters
$fix = array("<",">","(",")","{","}","[","]"); // a array set up with all of the invalid characters
$new = str_replace($fix,' ',$codetoreplace); // replaces the invalid characters with a space (space can be taken out)
echo $new; //echos y o fff yy ggg ffff
?>
Last edited by nickman013 on Wed Mar 01, 2006 1:21 pm, edited 2 times in total.
-
anthony88guy
- Forum Contributor
- Posts: 246
- Joined: Thu Jan 20, 2005 8:22 pm