3v4l.org

run code in 300+ PHP versions simultaneously
<?php $characters = ['a', 'b', 'c']; $string = 'cccc'; $characters = array_flip($characters); $base = count($characters); $chrs_to_ords = array_map( function (string $char) use ($characters) : int { return $characters[$char]; }, preg_split('//u', $string, -1, \PREG_SPLIT_NO_EMPTY) ); $ords = implode('', $chrs_to_ords); $baseN = base_convert($ords, $base, 10); $length = strlen($baseN); $next_number = str_pad($baseN + 1, $length, '0', \STR_PAD_LEFT); $next_number = base_convert($next_number, 10, $base); $characters = array_flip($characters); $next_chars = array_map( function(int $ord) use ($characters) { return $characters[$ord]; }, str_split($next_number) ); $next_string = implode('', $next_chars); var_dump($next_string);
Output for git.master, git.master_jit, rfc.property-hooks
string(5) "baaaa"

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:
127.19 ms | 405 KiB | 5 Q