fork(1) download
  1. <?php
  2. $string = <<<EOF
  3. My cousin lives pri City.
  4. Ja som bol vo Velkom Krtisi.
  5. Dnes som jedol palacinky v Dubnici nad Vahom.
  6. Velky Krtis je male mesto.
  7. EOF;
  8. preg_match_all('/\b(?:vo?|pri|od|do|z|nad?)((?:\s+[a-z]+){1,3})/i', $string, $matches, PREG_OFFSET_CAPTURE);
  9. print_r($matches[1]);
  10.  
  11. preg_match_all('/\b(?:vo?|pri|od|do|z|nad?)((?:\s+[a-z]+){1,3})/i', $string, $matches);
  12. print_r($matches[1]);
  13. ?>
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [0] =>  City
            [1] => 19
        )

    [1] => Array
        (
            [0] =>  Velkom Krtisi
            [1] => 39
        )

    [2] => Array
        (
            [0] =>  Dubnici nad Vahom
            [1] => 81
        )

)
Array
(
    [0] =>  City
    [1] =>  Velkom Krtisi
    [2] =>  Dubnici nad Vahom
)