- var_export: documentation ( source)
- preg_replace: documentation ( source)
<?php
$names = [
" barira, stefan",
"cikka , maria",
"luppo, martin ",
"bill,sebastian",
"van gogh , mary jane",
];
var_export(
preg_replace('~^\s*([^,]+?)\s*,\s*(.*?)\s*$~', '$2 $1', $names)
);