3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $token_list = str_split("apt71hfmh618k17dgimvltrn06"); $first = null; $second = null; $modified_list = $token_list; for($i = 0; $i < count($token_list); $i++) { if(!is_nan($token_list[$i]) && $i > 4 && $i < count($token_list) -4) { if(is_null($first)) { $first = $i; } } elseif(is_null($second)) { $second = $i; } } if(!is_null($first) && !is_null($second)) { $modified_list[$first] = $token_list[$second]; $modified_list[$second] = $token_list[$first]; } else { $modified_list[12] = $token_list[13]; $modified_list[13] = $token_list[12]; } $modified_token = implode('', $modified_list); var_dump($token_list); var_dump($modified_token);
based on S9LZo
Output for 7.0.0 - 7.2.0
Warning: is_nan() expects parameter 1 to be float, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be float, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be float, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be float, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be float, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be float, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be float, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be float, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be float, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be float, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be float, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be float, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be float, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be float, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be float, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be float, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be float, string given in /in/NODdk on line 12 array(26) { [0]=> string(1) "a" [1]=> string(1) "p" [2]=> string(1) "t" [3]=> string(1) "7" [4]=> string(1) "1" [5]=> string(1) "h" [6]=> string(1) "f" [7]=> string(1) "m" [8]=> string(1) "h" [9]=> string(1) "6" [10]=> string(1) "1" [11]=> string(1) "8" [12]=> string(1) "k" [13]=> string(1) "1" [14]=> string(1) "7" [15]=> string(1) "d" [16]=> string(1) "g" [17]=> string(1) "i" [18]=> string(1) "m" [19]=> string(1) "v" [20]=> string(1) "l" [21]=> string(1) "t" [22]=> string(1) "r" [23]=> string(1) "n" [24]=> string(1) "0" [25]=> string(1) "6" } string(26) "hpt71afmh618k17dgimvltrn06"
Output for 5.3.19 - 5.6.28
Warning: is_nan() expects parameter 1 to be double, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be double, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be double, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be double, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be double, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be double, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be double, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be double, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be double, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be double, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be double, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be double, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be double, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be double, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be double, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be double, string given in /in/NODdk on line 12 Warning: is_nan() expects parameter 1 to be double, string given in /in/NODdk on line 12 array(26) { [0]=> string(1) "a" [1]=> string(1) "p" [2]=> string(1) "t" [3]=> string(1) "7" [4]=> string(1) "1" [5]=> string(1) "h" [6]=> string(1) "f" [7]=> string(1) "m" [8]=> string(1) "h" [9]=> string(1) "6" [10]=> string(1) "1" [11]=> string(1) "8" [12]=> string(1) "k" [13]=> string(1) "1" [14]=> string(1) "7" [15]=> string(1) "d" [16]=> string(1) "g" [17]=> string(1) "i" [18]=> string(1) "m" [19]=> string(1) "v" [20]=> string(1) "l" [21]=> string(1) "t" [22]=> string(1) "r" [23]=> string(1) "n" [24]=> string(1) "0" [25]=> string(1) "6" } string(26) "hpt71afmh618k17dgimvltrn06"