fork download
  1. <?php
  2.  
  3. $text = "ghi ác xyz ác, jkl";
  4. $search = "ác";
  5. $_x_word = '/\s(' . preg_quote($search) . ')\s/i';
  6. preg_match_all($_x_word, $text, $match_words);
  7. var_dump($match_words);
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
array(2) {
  [0]=>
  array(1) {
    [0]=>
    string(5) " ác "
  }
  [1]=>
  array(1) {
    [0]=>
    string(3) "ác"
  }
}