I cant find a way to properly escape the special characters for php code
evaluation (iam sure its something simple) Can some one point this out?
[errors generated]
Parse error: parse error, unexpected ']'
Fatal error: Failed evaluating code: $color[!]
[function containing error]
function HTMLfromNickName ( $player ) {
$color=array(
//numeric
"1"=>"","2"=>"","3"=>"","4"=>"","5"=>"","6"=>"","7"=>"","8"=>"","9"=>"","0"=>"",
//Caps
"Q"=>"","W"=>"","E"=>"","R"=>"","T"=>"","Y"=>"","U"=>"","I"=>"","O"=>"","P"=>"","A"=>"","S"=>"","D"=>"","F"=>"","G"=>"","H"=>"","J"=>"","K"=>"","L"=>"","Z"=>"","X"=>"","C"=>"","V"=>"","B"=>"","N"=>"","M"=>"",
//lower
"q"=>"","w"=>"","e"=>"","r"=>"","t"=>"","y"=>"","u"=>"","i"=>"","o"=>"","p"=>"","a"=>"","s"=>"","d"=>"","f"=>"","g"=>"","h"=>"","j"=>"","k"=>"","l"=>"","z"=>"","x"=>"","c"=>"","v"=>"","b"=>"","n"=>"","m"=>"",
//special
"!"=>"","@"=>"","#"=>"","\$"=>"","\%"=>"","\&"=>"","*"=>"","("=>"",")"=>"","_"=>"","-"=>"","+"=>"","="=>"","["=>"","]"=>"","{"=>"","}"=>"","'"=>"","\""=>"","?"=>"","/"=>"","|"=>"",","=>"","."=>"","<"=>"",">"=>"",":"=>"",";"=>""
);
//todo: include special characters
$end = $end + substr_count ($player, "^");
$player = preg_replace("/\^(.)/ex", '$color[$1]', $player);
$player .= str_repeat ("", $end);
return $player;
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php