3v4l.org

run code in 300+ PHP versions simultaneously
<?php class LookAndSay { private static function tokenize($input) { $currentDigit = substr($input, 0, 1); $n = 0; $result = []; foreach(str_split($input) as $digit) { if($currentDigit !== $digit) { $result[] = [$currentDigit, $n]; $n = 0; $currentDigit = $digit; } $n++; } $result[] = [$currentDigit, $n]; return $result; } public static function transform($input) { $tokens = self::tokenize($input); $result = ''; foreach($tokens as $token) { list($digit, $n) = $token; $result .= $n . $digit; } return $result; } } $input = '3113322113'; for($i = 0; $i < 40; $i++) {gc_collect_cycles(); $input = LookAndSay::transform($input);} print strlen($input);
Output for git.master, rfc.property-hooks
Fatal error: Out of memory (allocated 33558528 bytes) (tried to allocate 2097160 bytes) in /in/NPnJ8 on line 11 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for git.master_jit
Fatal error: Out of memory (allocated 18878464 bytes) (tried to allocate 4096 bytes) in /in/NPnJ8 on line 11 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
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:
55.6 ms | 401 KiB | 8 Q