• 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

php 7 php.ini upload_max_filesize not working

Warning: A non-numeric value encountered

OAuth2 Token PHP

How to display table header in every page using FPDF library?

How to increase the PHP upload limits [duplicate]

Insert multidimensional array to codeigniter cart

Symfony - EasyAdmin - Add and remove functions are ignored from AssociationField

Why i get wrong output for html markdown?

How to remove index.php and index from the URL using htaccess | PHP

Creating command to backup MySql database in Laravel

How do I pass the dynamic output of a php variable or php function to a CSS variable?

Show only featured products in Woocommerce shop page

How can I get data from PHP to Android TextView?

CodeIgniter 4: Like and Dislike Functionality

Display a success custom notice after Placing an Order in WooCommerce

About Contact Privacy policy Terms and conditions