I want to highlight my search query on a formatted number.
For example:
$search_query = '1234'; // or $search_query = '7800';
$formatted_numeber = 12,345,678.00;
Currently my code is:
preg_replace('/(' . $search_query . ')/i', "<span style='background: yellow'>$1</span>", $formatted_numeber);
But this code fails to highlight search clause like ‘1234’ , ‘7800’ due to presence of commas (,) and decimal (.)
Also i want this to work with the presence of commas and decimals in the search query.
For example:
$search_query = '3,456';
$formatted_numeber = 12,345,678.00;
I want to highlight the part “345,6” on my formatted number.
Or:
$search_query = '7.80';
$formatted_numeber = 12,345,678.00;
I want to highlight the part “78.0” on my formatted number.