$hexURLCodes =array("+%20+","+%21+","+%2A+","+%27+","+%28+","+%29+","+%3B+","+%24+","+%2C+","+%25+","+%5B+","+%5D+"); $reservedURLChars = array (" ","!","*","'","(",")",";","$","%","[","]"); for($countI = 0; $countI < sizeof($reservedURLChars); $countI++) { $url = str_replace($reservedURLChars[$countI], $hexURLCodes[$countI], $url); }