3v4l.org

run code in 300+ PHP versions simultaneously
<?php $r = md5(rand().microtime(TRUE)); $_POST = [ $r => 'theSubmittedUsername', '__autocomplete_fix_' . $r => 'username' ]; foreach ($_POST as $key => $val) { $newKey = preg_replace('~^__autocomplete_fix_~', '', $key, 1, $count); if ($count) { $_POST[$val] = $_POST[$newKey]; unset($_POST[$key], $_POST[$newKey]); } } var_export($_POST);
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.21, 7.4.0 - 7.4.9, 8.0.0alpha1 - beta2
array ( 'username' => 'theSubmittedUsername', )