Enlight a word from text


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $text = "Sample sentence from KomunitasWeb, regex has become popular in web programming. Now we learn regex. According to wikipedia, Regular expressions (abbreviated as regex or regexp, with plural forms regexes, regexps, or regexen) are written in a formal language that can be interpreted by a regular expression processor";
  2. $text = preg_replace("/b(regex)b/i", '<span style="background:#5fc9f6">1</span>', $text);
  3. echo $text;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.