3v4l.org

run code in 500+ PHP versions simultaneously
<?php function lookAndSay(int $n): string { if ($n <= 1) return '1'; $r = $lastSeq = '1'; while($n-- > 0) $r .= ' '.($lastSeq = tokenize($lastSeq)); return $r; } function tokenize(string $str): string { $r = ''; $c = 1; for ($i = 0; $i < strlen($str); $i++) { if($str[$i] == ($str[$i + 1] ?? '')) { $c++; continue; } ($r .= $c.$str[$i]) && ($c = 1); } return $r; } echo lookAndSay(3);
Output for git.master, git.master_jit, rfc.property-hooks
1 11 21 1211

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:
36.86 ms | 861 KiB | 4 Q