• 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

How to fix Call to undefined method AppModelsTableName::factory?

Docker & Laravel : configure: error: Package requirements (oniguruma) were not met

Yii2: How do I debug console commands?

Multiple order by in WooCommerce

laravel automatically deletes server.php on php artisan serve

Navigation idle on content download

hidden INPUT value not available in $_POST

Custom add to cart button URL for specific product in WooCommerce?

PHP: Convert any string to UTF-8 without knowing the original character set, or at least try

The sum of the user's points

Unable to Edit config.inc.php

Laravel update hasMany relationship using saveMany

Could not decode a text frame as UTF-8.

Autoloading classes in PHPUnit using Composer and autoload.php

VB.NET WebRequest with PHP POST

About Contact Privacy policy Terms and conditions