fork download
  1. <?php
  2.  
  3. function localizacion($linea)
  4. {
  5. $re = '/([^)(]+),\s*([^)(]+)\)\.\s*Extraído/m';
  6. preg_match_all($re, $linea, $matches, PREG_SET_ORDER, 0);
  7. return(array($matches[0][1], $matches[0][2]));
  8. }
  9.  
  10. var_dump(localizacion('"Fuel to burn", de Aerogramme (Glasgow, Escocia). Extraído de su EP "Glam cripple EP (Fukd I.D. #1)".'));
  11. var_dump(localizacion('"You\'re pretty good looking (for a girl)", de The White Stripes (Detroit, EEUU). Extraído de su LP "De stijl".'));
  12.  
Success #stdin #stdout 0s 82624KB
stdin
Standard input is empty
stdout
array(2) {
  [0]=>
  string(7) "Glasgow"
  [1]=>
  string(7) "Escocia"
}
array(2) {
  [0]=>
  string(7) "Detroit"
  [1]=>
  string(4) "EEUU"
}