• 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

zsh: command not found: php

Shopify password update using Shopify API

Laravel get user data with profile

google content api for shopping

PHPMetrics option --excluded-dirs="myfolder" : myfolder dir is not excluded within docker

Cut an arabic string

how to remove white space in select 2

Create a zip file and download it

Laravel 5: Is there a non-case sensitive way to sort a collection by an attribute?

str_replace or preg_replace random number from string

MySQL - Connection failed: No route to host

Laravel PHP: multiple project run at the same time [closed]

Get latest Tweets - What API

stay with the last 15 elements of an array [duplicate]

Object of class stdClass could not be converted to string error

About Contact Privacy policy Terms and conditions