fork(1) download
  1. <?php
  2. function removeDaDeDiDoDu($name) {
  3. $name = preg_replace('/\s(d[A-z]{1,2}|a(.){1,2}?|e(.){1,2}?|le{1}|[A-z.]{1,2}\s)/i',' ',$name);
  4. return preg_replace('/\s\s+/i',' ', $name);
  5. }
  6.  
  7. $names = array(
  8. 'Márcio da Silva da Costa',
  9. 'Lucas Oliveira Xavier',
  10. 'Wallace de Souza',
  11. 'Sandra de A. Pereira',
  12. 'Murilo a Souza',
  13. 'Fernanda e Silva',
  14. );
  15. foreach($names as $k => $name) {
  16. $names[$k] = removeDaDeDiDoDu($name);
  17. }
  18. print_r($names);
  19.  
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Márcio Silva Costa
    [1] => Lucas Oliveira Xavier
    [2] => Wallace Souza
    [3] => Sandra Pereira
    [4] => Murilo Souza
    [5] => Fernanda Silva
)