3v4l.org

run code in 300+ PHP versions simultaneously
<?php function strToHex($string) { $hex=''; for ($i=0; $i < strlen($string); $i++) { $hex .= dechex(ord($string[$i])); } return $hex; } function hexToStr($hex) { $string=''; for ($i=0; $i < strlen($hex)-1; $i+=2) { $string .= chr(hexdec($hex[$i].$hex[$i+1])); } return $string; } $test = "ffff:eeee:dddd:cccc:bbbb:aaaa:9999:8888"; $testParts = explode(':', $test); $testHex = array(); foreach($testParts as $testPart){ array_push($testHex, $testPart); //echo strToHex($testPart) . "<br>\n"; } $packed = pack('H H H H H H H H', $testParts[0], $testParts[1], $testParts[2], $testParts[3], $testParts[4], $testParts[5], $testParts[6], $testParts[7]); $unpacked = unpack('H H H H H H H H', $packed); $unpackedString = array(); //var_dump($testParts); //var_dump($testHex); var_dump($packed); var_dump($unpacked); foreach($unpacked as $unpack){ array_push($unpackedString, $unpack); } echo implode(':', $unpackedString); ?>
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught ValueError: Type : unknown format code in /in/NVhuV:32 Stack trace: #0 /in/NVhuV(32): pack('H H H H H H H H', 'ffff', 'eeee', 'dddd', 'cccc', 'bbbb', 'aaaa', '9999', '8888') #1 {main} thrown in /in/NVhuV on line 32
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.49 ms | 401 KiB | 8 Q