3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'The dog ate the cat and the dog ate the chimp'; $find = 'dog'; $array = ['duck', 'pig']; $count = 1; while ($array && $count) { $string = preg_replace("#$find#", array_shift($array), $string, 1, $count); } echo $string;

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
176.46 ms | 1601 KiB | 10 Q