fork download
  1. <?php
  2.  
  3.  
  4. $arr=array("I used to live in <Location>London</Location>.",
  5. "I work for <Organization> Microsoft Tech.</Organization>
  6. which is in <Location>London</Location>");
  7.  
  8. foreach ($arr as $str) {
  9. preg_match('/(?:[<>\/\w]+\s*){4}(?=<Location>)/s', $str, $m );
  10. var_dump($m[0]);
  11. }
  12. ?>
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
string(16) "used to live in "
string(28) "</Organization>
which is in "