note 35696 modified in function.bin2hex by vincent

From: Date: Thu, 11 Sep 2003 12:35:28 +0000
Subject: note 35696 modified in function.bin2hex by vincent
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-56118@lists.php.net to get a copy of this message
A silly hack (which could prove to have some usefulness) to create a "progress indikator" using Andreas Schmeiler's hex2bin: Run this in command line: #!/usr/bin/php4 -q <? $progress1="."; $progress2=":"; $progress=$progress1; function hex2bin($hexdata) {         for ($i=0;$i<strlen($hexdata);$i+=2)         {                 $bindata.=chr(hexdec(substr($hexdata,$i,2)));         }         return $bindata; } for($i=0;$i<50000; $i++) {         sleep(1);         echo ($progress==$progress1) ? $progress=$progress2 : $progress=$progress1;         echo hex2bin("08"); } ?> NB: The sleep function is only for demonstration purpose :) Also the 08 migth be OS dependent, this code has been tested on linux only. --was-- A silly hack (which could prove to have some usefulness) to create a "progress indikator" using Andreas Schmeiler's hex2bin: Run this in command line: #!/usr/bin/php4 -q <? $progress[]="|"; $progress[]="/"; $progress[]="-"; $progress[]="\\"; function hex2bin($hexdata) { for ($i=0;$i<strlen($hexdata);$i+=2) { $bindata.=chr(hexdec(substr($hexdata,$i,2))); } return $bindata; } for($i=0;$i<50000; $i++) { foreach($progress as $key) { sleep(1); echo $key.hex2bin("08"); } } ?> NB: The sleep function is only for demonstration purpose :) Also the 08 migth be OS dependent, this code has been tested on linux only. http://www.php.net/manual/en/function.bin2hex.php

« previous php.notes (#56118) next »