3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'bears, tigers, lions, sword-1,2-fish, penguins'; $explodedArray = explode(' ',$string); array_walk($explodedArray, function(&$value, &$key) { $value = rtrim($value,','); }); print_r($explodedArray);

preferences:
64.03 ms | 402 KiB | 5 Q