3v4l.org

run code in 300+ PHP versions simultaneously
<?php $commands = array("mark", "ignore", "pick", "random"); $attempts = array("mark", "ignore", "pick", "random", "bonk"); foreach($attempts as $attempt){ echo "$attempt => "; $index=array_search($attempt,$commands); if($index===false || !isset($commands[++$index])){ // not found or found last element $index=0; // use first element } echo $commands[$index],"\n"; }

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
151.11 ms | 2027 KiB | 9 Q