3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_next_colid(string $id): string { if ($id === '') { return "\0"; } $chrs = str_split($id); $bytes = array_map(fn(string $chr): int => ord($chr), $chrs); $last = array_pop($bytes); $last++; $bytes[] = $last; $reveresed = array_reverse($bytes); foreach($reveresed as $pos => $val) { if ($val > 255) { $reveresed[$pos] = 255; if (isset($reveresed[$pos+1])) { $reveresed[$pos+1] += ($val - 255); } else { $reveresed[$pos+1] = ($val - 255); } } } $bytes = array_reverse($reveresed); $chrs = array_map(fn(int $byte): string => chr($byte), $bytes); return join('', $chrs); } var_dump( get_next_colid(''), get_next_colid('hello'), get_next_colid('world'), get_next_colid('a'), get_next_colid('c'), get_next_colid('🔗'), );
Output for git.master_jit, git.master, rfc.property-hooks
string(1) "" string(5) "hellp" string(5) "worle" string(1) "b" string(1) "d" string(4) "🔘"

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:
63.81 ms | 1265 KiB | 4 Q