<?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);
- Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
- array (
0 => 'string',
1 => 'apple',
2 => 'orange',
)
----
array (
0 => 'string',
1 => 'apple',
2 => 'orange',
)
preferences:
92.7 ms | 403 KiB | 163 Q