RE: [PHP-NOTES] note 10287 added to bin2hex

From: Date: Sun, 24 Dec 2000 13:54:48 +0000
Subject: RE: [PHP-NOTES] note 10287 added to bin2hex
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-9057@lists.php.net to get a copy of this message
You would reall want to use urlencode() and rawurlencode(), this is quicker as its an internal function. James > -----Original Message----- > From: wigwam@bigfoot.de [mailto:wigwam@bigfoot.de] > Sent: 24 December 2000 13:41 > To: php-notes@lists.php.net > Subject: [PHP-NOTES] note 10287 added to bin2hex > > > 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 > > > -- > PHP Notes Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-notes-unsubscribe@lists.php.net > For additional commands, e-mail: php-notes-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.notes (#9057) next »