• 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

Trying to iterate over a mongodb cursor twice - failing

Using PHP to connect to a remote MSSQL database

Problem with fetching data from database in Laravel

How to debug in WooCommerce 3+

Php - Sum up the numbers in an array one by one

JQuery content editable div and text box on submit not sending POST

Transform array, set each array element with parent key php

How to get quarter for future date using Carbon?

generating a random code in php?

Make survey at laravel 5.4 and MySQL

Laravel passport auth token not working after moving to different server

Error converting docx to pdf using Unoconv

How to Install Composer Require doctrine/dbal

How to identify whether webp image is static or animated?

how to loop through json response data using ajax jquery?

About Contact Privacy policy Terms and conditions