• 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

Composer Warning: openssl extension is missing. How to enable in WAMP

Why i get wrong output for html markdown?

dockerizing Laravel + vue

Laravel Database Strict Mode

Symfony Error: "An exception has been thrown during the rendering of a template"

Vimeo API: how to save a vimeo into a subfolder?

"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP

how to sort by a custom appended relation to model

Cannot connect to own websocket server when on secured domain

OctoberCMS / Anonymous Global Scope

PHP Get value from JSON [duplicate]

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

How do I loop through an MS SQL database with VB.NET?

How can I pass the list to the component variable in Laravel?

woocommerce get_order_report_data to show order_item_id

About Contact Privacy policy Terms and conditions