note 10286 added to bin2hex
| From: | wigwam at bigfoot dot de | Date: | Sun, 24 Dec 2000 13:38:15 +0000 |
| Subject: | note 10286 added to bin2hex | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-9053@lists.php.net to get a copy of this message | ||
This is useful if you want to give parameters to your script via links (and not forms). Then you
need to change some chars into their hex-numbers. E.g. space to %20.
function asc2form ($input) {
$nochange = array
("a","b","c","d","e","f","g",
"h","i","j","k","l","m","n",
"o","p","q","r","s","t","u","v","w","x","y","z",
"A","B","C","D","E","F","G","H","I","J","K","L","M","N",
"O","P","Q","R","S","T","U","V","W","X","Y","Z",
"0","1","2","3","4","5","6","7","8","9","_","-");
for ($i=0;$i<strlen($input);$i++) {
$char = substr($input,$i,1);
if (in_array($char,$nochange)) {
$ret .= $char;
} else {
$ret .= "%".bin2hex($char);
}
return $ret;
}
http://www.php.net/manual/function.bin2hex.php