3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = ["string|||mfasdfhadskjfahsldfhcadkasldhfaf", "apple|||2345hrquwfiqfh4fhlqwu4f", "orange|||0erjoerhtqothcro"]; var_export(preg_replace('~\|.*~', '', $array)); echo "\n----\n"; foreach ($array as &$value) { $value = strstr($value, '|', true); } var_export($array);

preferences:
25.03 ms | 402 KiB | 5 Q