note 24548 added to function.bin2hex

From: Date: Wed, 21 Aug 2002 06:27:22 +0000
Subject: note 24548 added to function.bin2hex
Groups: php.notes 
Request: Send a blank email to php-notes+get-35292@lists.php.net to get a copy of this message
Hopefully this helps someone... It just displays an html representation of hex data, much like a hex viewer would. Matt ---- PS - you may have to indent it yourself - the formatting of the notes doesn't seem to be quite right. ---- function hexview($data){ $bytePosition = $columnCount = $lineCount = 0; $columns = 8; $dataLength = strlen($data); $return = array(); $return[] = '<table border="1" cellspacing="0" cellpadding="2">'; for($n = 0; $n < $dataLength; $n++){ $lines[$lineCount][$columnCount++] = substr($data, $n, 1); if($columnCount == $columns){ $lineCount++; $columnCount = 0; } } foreach($lines as $line){ $return[] = '<tr><td align="right">'.$bytePosition.': </td>'; for($n = 0; $n < $columns; $n++){ $return[] = '<td>'.strtoupper(bin2hex($line[$n])).'</td>'; } $return[] = '<td> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>'; for($n = 0; $n < $columns; $n++){ $return[] = '<td>'.(htmlentities($line[$n]) ? htmlentities($line[$n]) : '&nbsp;').'</td>'; } $return[] = '</tr>'; $bytePosition = $bytePosition + $columns; } $return[] = '</table>'; return implode('', $return); } -- http://www.php.net/manual/en/function.bin2hex.php http://master.php.net/manage/user-notes.php?action=edit+24548 http://master.php.net/manage/user-notes.php?action=delete+24548 http://master.php.net/manage/user-notes.php?action=reject+24548

« previous php.notes (#35292) next »