3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_next_colid(string $id): string { $length = \strlen($id); for ($i = $length - 1; $i >= 0; $i--) { if ($id[$i] === "\xff") { $id[$i] = "\0"; continue; } $id[$i] = \chr(\ord($id[$i]) + 1); return $id; } return str_repeat("\0", $length + 1); } 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 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
string(1) "" string(5) "hellp" string(5) "worle" string(1) "b" string(1) "d" string(4) "👎"

preferences:
68.2 ms | 1250 KiB | 4 Q