note 36969 added to function.bin2hex
| From: | mkr at binarywerks dot dk | Date: | Wed, 29 Oct 2003 10:34:45 +0000 |
| Subject: | note 36969 added to function.bin2hex | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-59461@lists.php.net to get a copy of this message | ||
Ok, this is a better version than my previous poor example.
Running this in shell creates a progress indicator. Very useful if used when parsing large log files
for instance.
#!/usr/bin/php4 -q
<?
// Displays a progress indicator
function progress($line)
{
global $last_len;
$del_char = pack("H" . 2, "7F");
$line_len = strlen($line);
$del_chars=(isset($last_len)) ? $last_len : $line_len;
$last_len = $line_len;
return str_repeat($del_char, ($del_chars)).$line;
}
// demo code:
for($i=0;$i<100;$i++)
{
sleep(1);
echo progress("i is now: $i out of 100");
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.bin2hex.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+36969
Delete -- http://master.php.net/manage/user-notes.php?action=delete+36969&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+36969&report=yes
Search -- http://master.php.net/manage/user-notes.php