3v4l.org

run code in 300+ PHP versions simultaneously
<?php $one = "4,5,5,4,7"; $two = "3,5,6,4,2"; $aone = explode(",", $one); $atwo = explode(",", $two); $result= ""; For($i=0;$i<count($aone);$i++){ If($atwo[$i] > $aone[$i]){ $result[] = $atwo[$i]; }else{ $result[] = $aone[$i]; } } Var_dump($result); $str = implode(",", $result); Echo $str;
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: [] operator not supported for strings in /in/SuNsI:14 Stack trace: #0 {main} thrown in /in/SuNsI on line 14
Process exited with code 255.
Output for 5.5.0 - 5.5.36, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20
array(5) { [0]=> string(1) "4" [1]=> string(1) "5" [2]=> string(1) "6" [3]=> string(1) "4" [4]=> string(1) "7" } 4,5,6,4,7

preferences:
196.48 ms | 402 KiB | 259 Q