• 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

Unable to guess the mime type as no guessers are available Laravel 5.2

PHP - Store information with NO database

Can't find vendor/autoload.php for Ratchet

PHP Download MP3 files from directory on server

Use same method for inertia response and json response Laravel Jetstream

Normalize DateInterval in PHP

java URL working on browser but not in client program

Add Class in html Dynamically in PHP

Changing font color in javascript

I can't delete my image when it is liked because of the foreign key in mysql

Display specific shipping method if woocommerce product has specific acf field value

Laravel post contact form giving me error 419

Error converting docx to pdf using Unoconv

Insert And Retrieve Data in MySQL with $.post Noob Question

Add record for each array elements if missing in table

About Contact Privacy policy Terms and conditions