Perform POST submission
What it results in is this.
Nothing submitted.  Click one of the buttons above to get things working.
_POST data is:

<?php
function display_packets($packets) {
    
ksort($packets);
    foreach ( 
$packets AS $packet_id => $packet ) {
        if ( ! 
is_string($packet) ) {
            echo 
"{$packet_id} is not a string!\n";
            continue;
        }
        echo 
"Name is {$packet_id}\n";
        
display_packet($packet);
    }
}
function 
display_packet($packet) {
    
$starting_char    0;
    
$increment_by    16;
    for( 
$i=$starting_char$i<strlen($packet); $i+=16 ) {
        echo 
str_pad(sprintf("%X"$i), 4'0'STR_PAD_LEFT);
        foreach ( array(
0,8) AS $setID => $a ) {
            
$display[$setID] = '';
            echo 
' ';
            for ( 
$b=0$b<8$b++ ) {
                if ( isset(
$packet[($i+$a+$b)]) ) {
                    
$ord ord($packet[($i+$a+$b)]);
                    echo 
' '.str_pad(sprintf("%X"$ord), 2'0'STR_PAD_LEFT);
                    
$chr chr($ord);
                    if ( 
preg_match('![\w\d\!@#$%^&*\(\)/\`~<>?.,;:"\'\[\]\{\}|\\_=+-]!'$chr) ) {
                        
$display[$setID] .= $chr;
                    } else {
                        
$display[$setID] .= '.';
                    }
                } else {
                    echo 
'   ';
                }
            }
        }
        echo 
'  '.str_pad($display[0], 8' ').' '.str_pad($display[1], 8' ')."\n";
    }
}
?>
<style> div, pre { padding: 1em; border:1px solid black }</style>
<div>
Perform POST submission
<form method="post" action="form_encoding.php">
<input type="submit" name="submit" value="&nbsp; &nbsp; Click Me! &nbsp; &nbsp;" />
</form>
</div>
What it results in is this.
<pre><?php echo (isset($_REQUEST['submit']) ? trim($_REQUEST['submit'], "\xA0\x20"): 'Nothing submitted.  Click one of the buttons above to get things working.'); ?></pre>
<pre><?php
if ( isset($_POST) ) {
    echo 
"_POST data is:\n";
    
display_packets($_POST);
}
?></pre>
<hr>
<?php highlight_file(basename($_SERVER['SCRIPT_NAME'])); ?>