Search
 
SCRIPT & CODE EXAMPLE
 

PHP

highlight search text in php

function highlightWords($text, $word){
    $text = preg_replace('#'. preg_quote($word) .'#i', '<span style="background-color: #F9F902;"></span>', $text);
    return $text;
}

//function calling
highlightWords($desc, $search_word);
Comment

PREVIOUS NEXT
Code Example
Php :: php regex non capturing group 
Php :: php date today plus 1 month 
Php :: how to split url in php 
Php :: wp show logo 
Php :: re migrate laravel 
Php :: laravel database connection check 
Php :: wordpress on publish hook 
Php :: get category name by id wordpress 
Php :: setcookie php 
Php :: check if array has value php 
Php :: php date strtotime add days 
Php :: make a seeding file in laravel 
Php :: Check duplicate email in laravel using jQuery validation 
Php :: php multiple line string 
Php :: get file each line in php 
Php :: laravel log permission denied mac 
Php :: laravel request validation boolean 
Php :: php how to count array 
Php :: laravel helper function for check string is exist in another string 
Php :: is php still used 
Php :: laravel increment column value in update query 
Php :: Extract images from a folder in php 
Php :: Split 10 email out of 50 email using coma separated via php 
Php :: CGST/SGST calculate in laravel 8 
Php :: Search for text in string php 
Php :: snap remove php stome 
Php :: get current route laravel 
Php :: get country from ip php 
Php :: php delete item from array 
Php :: php get intersection of two arrays 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =