Forum Moderators: coopster
function myEncode($ff){
$un = array('%',' ','{','}','~','<','>','!','"','$','&','+',',','/',':',';','=','?','@');
$nn = array('%25','%20','%7b','%7d','%7e','%3c','%3e','%21','%22','%24','%26','%2b','%2c','%2f','%3a','%3b','%3d','%3f','%40');
foreach($un as $k => $v) {
$ff = ereg_replace($v,$nn[$k],$ff);
}
return $ff;
}
it echo's
Warning: ereg_replace(): REG_BADRPT
Your solution is kind of an 'abuse' of ereg_replace() which accepts regular expressions and not plain strings. In regular expressions some characters have a special meaning. For example, a curly bracket introduces a repetition. But it needs to be followed by a number and a closing curly bracket. Hence the error message.
I think I've got them all below...
$un = array('%',' ','{','}','~','<','>','!','"','\$','&','\+',',','/',':',';','=','\?','@');