3v4l.org

run code in 300+ PHP versions simultaneously
<?php method_exists('SplFileObject', 'fread') or die("No SplFileObject::fread()"); $width = 16; $hex_width = 3 * $width; $file = new SplFileObject(__FILE__); while ($file->valid()) { $chunk = $file->fread($width); $hex = array_map(function ($char) { return sprintf('%02X', ord($char)); }, str_split($chunk)); printf("%-' {$hex_width}s %s\n", implode(' ', $hex), preg_replace('/[^[:print:]]/', '.', $chunk)); }

preferences:
33.61 ms | 402 KiB | 5 Q