• 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

Multiply each value in array using array_map function

How can I format this number correctly using PHP?

Laravel Multi-language routes without prefix

How to modify CSS in a specific page of the WP admin dashboard (backend)

Converting IPv6 to IPv4 address in PHP

How to fix this error : Ask your hosting provider to use PHP 7.2.5 or higher for both HTTP and CLI?

PHP to search within txt file and echo the whole line

Symfony there are no commands defined in the "make" namespace

Error when uploading certain .png files "Interlace handling should be turned on when using png_read_image"

Get sum of arrays inside array

Getting output of MS stored procedure on php call

how to display a view on laravel 8 and not have a 404 NOT FOUND page?

The difference when using if statement true === something() vs something() === true [duplicate]

(Laravel) How to delete multiple models including optional relationships?

Filter WooCommerce products with post__in and additional meta queries

About Contact Privacy policy Terms and conditions