• 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

PDOException SQLSTATE[HY000] [2002] No such file or directory

PHP Imap , php 7.4.3 on mac osx catalina

Symfony - "framework.test" config is not set to true

Why isn't my PHP exception working?

java URL working on browser but not in client program

get folder directory from input type file - PHP

Laravel Nova Dependency Container what are the allowed resource properties other than id in dependsOn

Testing subscription renewals on Stripe

Additional price based on cart item count in WooCommerce

PHPS source file - 403 Forbidden You don't have permission to access this resource

PHP Array split string and Integers

Codeigniter, Severity: error --> Exception: Too few arguments to function, admin dashboard shows HTTP error 500

Remove categories with all childs derived from parent category

woocommerce get_order_report_data to show order_item_id

Laravel after login Two factor not working

About Contact Privacy policy Terms and conditions