3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php if (!function_exists('str_split')) { function str_split($text, $split = 1){ //place each character of the string into and array $array = array(); for($i=0; $i < strlen($text); $i++){ $key = NULL; for ($j = 0; $j < $split; $j++){ $key .= $text[$i]; } array_push($array, $key); } return $array; } } function hex_dump($data, $newline = "\n") { static $from = ''; static $to = ''; static $idxOffset = 8; static $width = 16; # number of bytes per line static $pad = '.'; # padding for non-visible characters static $hexPad = '00'; static $repeatHeadline = 5; if ($from === '') { for ($i = 0; $i <= 0xFF; ++$i) { $from .= chr($i); $to .= ($i >= 0x20 && $i <= 0x7E) ? chr($i) : $pad; } } $text = true; echo ($text) ? '' : '<pre>'; $head = str_repeat(' ', $idxOffset).' | '. implode(' ', array_map( create_function( '$str', 'return sprintf("%2X", $str);' ), range(0, $width - 1) )).' | '.(str_pad('', $width, '0123456789abcdef')).$newline; $separator = str_repeat('-', $idxOffset + 1).'+'.str_repeat('-', 3 * $width + 1).'+'. str_repeat('-', $width + 1).$newline; echo $head.$separator; $hex = str_split(bin2hex($data), $width * 2); $chars = str_split(strtr($data, $from, $to), $width); $hexLineBase = array_fill(0, $width, $hexPad); $offset = $c = 0; foreach ($hex as $i => $line) { $hexLine = str_split($line, 2) + $hexLineBase; $strLine = $chars[$i].str_repeat($pad, $width - strlen($chars[$i])); $line = sprintf('%'.$idxOffset.'X', $offset) . ' | ' . implode(' ', $hexLine) . ' | ' . $strLine . $newline; echo ($text) ? $line : htmlspecialchars($line); $offset += $width; if (++$c == $repeatHeadline) { echo $separator.$head.$separator; $c = 0; } } echo ($text) ? $newline.$newline : '<pre>'; } hex_dump(' \t\n\r\x0B'); hex_dump(" \t\n\r\x0B");
based on 9FgFp
Output for 5.0.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
| 0 1 2 3 4 5 6 7 8 9 A B C D E F | 0123456789abcdef ---------+-------------------------------------------------+----------------- 0 | 20 5c 74 5c 6e 5c 72 5c 78 30 42 00 00 00 00 00 | \t\n\r\x0B..... | 0 1 2 3 4 5 6 7 8 9 A B C D E F | 0123456789abcdef ---------+-------------------------------------------------+----------------- 0 | 20 09 0a 0d 0b 00 00 00 00 00 00 00 00 00 00 00 | ...............
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.3.0 - 4.4.9
| 0 1 2 3 4 5 6 7 8 9 A B C D E F | 0123456789abcdef ---------+-------------------------------------------------+----------------- 0 | 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 | 10 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | \\\\\\\\\\\\\\\\ 20 | 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 | tttttttttttttttt 30 | cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc | \\\\\\\\\\\\\\\\ 40 | 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 | nnnnnnnnnnnnnnnn ---------+-------------------------------------------------+----------------- | 0 1 2 3 4 5 6 7 8 9 A B C D E F | 0123456789abcdef ---------+-------------------------------------------------+----------------- 50 | 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 | \\\\\\\\\\\\\\\\ 60 | 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 | rrrrrrrrrrrrrrrr 70 | cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc | \\\\\\\\\\\\\\\\ 80 | 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 | xxxxxxxxxxxxxxxx 90 | ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee | 0000000000000000 ---------+-------------------------------------------------+----------------- | 0 1 2 3 4 5 6 7 8 9 A B C D E F | 0123456789abcdef ---------+-------------------------------------------------+----------------- A0 | 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 | BBBBBBBBBBBBBBBB Notice: Undefined offset: 11 in /in/HErET on line 62 Notice: Undefined offset: 11 in /in/HErET on line 62 B0 | cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc | ................ Notice: Undefined offset: 12 in /in/HErET on line 62 Notice: Undefined offset: 12 in /in/HErET on line 62 C0 | 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 | ................ Notice: Undefined offset: 13 in /in/HErET on line 62 Notice: Undefined offset: 13 in /in/HErET on line 62 D0 | 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 | ................ Notice: Undefined offset: 14 in /in/HErET on line 62 Notice: Undefined offset: 14 in /in/HErET on line 62 E0 | 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 | ................ ---------+-------------------------------------------------+----------------- | 0 1 2 3 4 5 6 7 8 9 A B C D E F | 0123456789abcdef ---------+-------------------------------------------------+----------------- Notice: Undefined offset: 15 in /in/HErET on line 62 Notice: Undefined offset: 15 in /in/HErET on line 62 F0 | cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc | ................ Notice: Undefined offset: 16 in /in/HErET on line 62 Notice: Undefined offset: 16 in /in/HErET on line 62 100 | 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 | ................ Notice: Undefined offset: 17 in /in/HErET on line 62 Notice: Undefined offset: 17 in /in/HErET on line 62 110 | 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 | ................ Notice: Undefined offset: 18 in /in/HErET on line 62 Notice: Undefined offset: 18 in /in/HErET on line 62 120 | 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 | ................ Notice: Undefined offset: 19 in /in/HErET on line 62 Notice: Undefined offset: 19 in /in/HErET on line 62 130 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ ---------+-------------------------------------------------+----------------- | 0 1 2 3 4 5 6 7 8 9 A B C D E F | 0123456789abcdef ---------+-------------------------------------------------+----------------- Notice: Undefined offset: 20 in /in/HErET on line 62 Notice: Undefined offset: 20 in /in/HErET on line 62 140 | 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 | ................ Notice: Undefined offset: 21 in /in/HErET on line 62 Notice: Undefined offset: 21 in /in/HErET on line 62 150 | 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 | ................ | 0 1 2 3 4 5 6 7 8 9 A B C D E F | 0123456789abcdef ---------+-------------------------------------------------+----------------- 0 | 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 | 10 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ 20 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ 30 | 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 | ................ 40 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ ---------+-------------------------------------------------+----------------- | 0 1 2 3 4 5 6 7 8 9 A B C D E F | 0123456789abcdef ---------+-------------------------------------------------+----------------- Notice: Undefined offset: 5 in /in/HErET on line 62 Notice: Undefined offset: 5 in /in/HErET on line 62 50 | aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa | ................ Notice: Undefined offset: 6 in /in/HErET on line 62 Notice: Undefined offset: 6 in /in/HErET on line 62 60 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ Notice: Undefined offset: 7 in /in/HErET on line 62 Notice: Undefined offset: 7 in /in/HErET on line 62 70 | dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd | ................ Notice: Undefined offset: 8 in /in/HErET on line 62 Notice: Undefined offset: 8 in /in/HErET on line 62 80 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ Notice: Undefined offset: 9 in /in/HErET on line 62 Notice: Undefined offset: 9 in /in/HErET on line 62 90 | bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb | ................ ---------+-------------------------------------------------+----------------- | 0 1 2 3 4 5 6 7 8 9 A B C D E F | 0123456789abcdef ---------+-------------------------------------------------+-----------------