<?php
function removeDaDeDiDoDu($name) {
$name = preg_replace('/\s(d[A-z]{1,2}|a(.){1,2}?|e(.){1,2}?|le{1}|[A-z.]{1,2}\s)/i',' ',$name); }
'Márcio da Silva da Costa',
'Lucas Oliveira Xavier',
'Wallace de Souza',
'Sandra de A. Pereira',
'Murilo a Souza',
'Fernanda e Silva',
);
foreach($names as $k => $name) {
$names[$k] = removeDaDeDiDoDu($name);
}
PD9waHAKZnVuY3Rpb24gcmVtb3ZlRGFEZURpRG9EdSgkbmFtZSkgewogICAgICAgJG5hbWUgPSBwcmVnX3JlcGxhY2UoJy9ccyhkW0Etel17MSwyfXxhKC4pezEsMn0/fGUoLil7MSwyfT98bGV7MX18W0Etei5dezEsMn1ccykvaScsJyAnLCRuYW1lKTsKICAgICAgIHJldHVybiBwcmVnX3JlcGxhY2UoJy9cc1xzKy9pJywnICcsICRuYW1lKTsKfQoKJG5hbWVzID0gYXJyYXkoCgknTcOhcmNpbyBkYSBTaWx2YSBkYSBDb3N0YScsCiAgICAnTHVjYXMgT2xpdmVpcmEgWGF2aWVyJywKICAgICdXYWxsYWNlIGRlIFNvdXphJywKICAgICdTYW5kcmEgZGUgQS4gUGVyZWlyYScsCiAgICAnTXVyaWxvIGEgU291emEnLAogICAgJ0Zlcm5hbmRhIGUgU2lsdmEnLAoJKTsKCWZvcmVhY2goJG5hbWVzIGFzICRrID0+ICRuYW1lKSB7CgkJICRuYW1lc1ska10gPSByZW1vdmVEYURlRGlEb0R1KCRuYW1lKTsKCX0KCXByaW50X3IoJG5hbWVzKTsK