- strstr: documentation ( source)
- var_export: documentation ( source)
- preg_replace: documentation ( source)
<?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);