- var_dump: documentation ( source)
- pack: documentation ( source)
- unpack: documentation ( source)
<?php
$str = 'Hello World!';
var_dump(\unpack('A16', \pack('A16', $str))[1]); // Decoding "space padded string" strips added spaces
var_dump(\unpack('a16', \pack('a16', $str))[1]); // Decoding "null padded string" leaves them there