- strstr: documentation ( source)
- var_export: documentation ( source)
<?php
$array = [
'x' => 'Laura Smith',
'y' => 'John. Smith',
'z' => 'John Doe'
];
foreach ($array as $key => $value) {
$array[$key] = strstr($value, ' ', true);
}
var_export($array);