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); } $s = '~'; for($i = 0; $i <= 1000; $i++) { $s = get_next_colid($s); } var_dump($s);
Output for 8.5.0 - 8.5.3
Deprecated: chr(): Providing a value not in-between 0 and 255 is deprecated, this is because a byte value must be in the [0, 255] interval. The value used will be constrained using % 256 in /in/MdlZB on line 28 Deprecated: chr(): Providing a value not in-between 0 and 255 is deprecated, this is because a byte value must be in the [0, 255] interval. The value used will be constrained using % 256 in /in/MdlZB on line 28 Deprecated: chr(): Providing a value not in-between 0 and 255 is deprecated, this is because a byte value must be in the [0, 255] interval. The value used will be constrained using % 256 in /in/MdlZB on line 28 string(2) "h�"
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
string(2) "h�"

preferences:
104.08 ms | 1237 KiB | 4 Q