• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Make certain characters of a word from string bold

phpregex


PHP Snippet 1:

$text = preg_replace('/\S*('. $searhPhrase .')\S*/i', '<b>$1</b>', $text);

PHP Snippet 2:

$text = preg_replace('/(\S*'. $searhPhrase .'\S*)/i', '<b>$1</b>', $text);

PHP Snippet 3:

function strReplace($searchText,$mainText){
    return str_replace($searchText, '<b>'.$searchText.'</b>', $mainText);
  }

Related Snippets

Multiple order by in WooCommerce

Dropdown with current value from Mysql

"Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page

How to get values inside <![CDATA[values]] > using php DOM?

Doctrine ORM: Excluding Records Based on Values of Nested Relationships

Pass a select with mysqli_fetch_row to a table

How do I refresh a DIV content?

WAMP Virtual Host not working

With doctrine ODM, can I embed many subdocuments in a main document?

PHP mail function is sending blank message body

How should I get started using PHPUnit as a testing framework for a bunch of functions and classes I have already made?

Match single unknown parameter php (Morse-code Regex)

The sum of the user's points

Converting array to string and then back in PHP

Why i get wrong output for html markdown?

About Contact Privacy policy Terms and conditions