• 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

Reading input in php from terminal

Add customer email and phone in "Order" column to admin orders list on Woocommerce

How do I remove this delivery notification from here?

how to validate form data in codeigniter 4

How to extract price from given url using Xpath?

Laravel Delete and Update

Add custom text under order details on WooCommerce My account view order pages

Pages are working fine on localhost but not running on the hosting server

generate an Excel file using PHP

Where do I need to place a hook for phpunit?

How to get AJAX to post on second page?

Any AWS EB Laravel route getting 404 Not Found nginx/1.16.1

How to get variable from JavaScript to PHP [duplicate]

how to search for a file with php

PHPExcel file download using AJAX call

About Contact Privacy policy Terms and conditions