fork(2) download
  1. <?php
  2.  
  3. function highlight_term($text, $words)
  4. {
  5. $i = preg_match_all('~[\p{L}\p{M}]+~u', $words, $m);
  6. if( $i == 0 )
  7. {
  8. return $text;
  9. }
  10.  
  11. $re = '~' . implode('|', $m[0]) . '~iu';
  12. return preg_replace($re, '<b>$0</b>', $text);
  13. }
  14.  
  15. $str = "ह ट इ ड यन भ भ और द";
  16.  
  17. echo highlight_term($str, 'और');
Success #stdin #stdout 0.01s 82944KB
stdin
Standard input is empty
stdout
ह ट इ ड यन भ भ <b>और</b> द