{"id":3927,"date":"2019-03-18T20:24:20","date_gmt":"2019-03-18T20:24:20","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=3927"},"modified":"2019-03-18T20:32:43","modified_gmt":"2019-03-18T20:32:43","slug":"highlight-keyword-in-search-results-php-mysql","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/highlight-keyword-in-search-results-php-mysql\/","title":{"rendered":"Highlight Keyword in Search Results with PHP and MySQL"},"content":{"rendered":"<p>Search functionality is very useful for the data list. It helps to find the relevant records quickly from the database. Search term highlighting feature makes the search functionality user-friendly. <b>Highlight keyword<\/b> helps the user to easily identify the more relevant records in search results.<\/p>\n<p>In the keywords highlighting feature, the search terms are highlighted with the different background color or text color in the search results. In this tutorial, we will show you how to search in MySQL database and <b>highlight keyword in search<\/b> results with PHP.<\/p>\n<h2>Highlight Words in Text<\/h2>\n<p>The <b>highlightWords()<\/b> is a custom function that helps to highlight the words in the text.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>The PHP <b>preg_replace()<\/b> function is used to perform a regular expression search and add a <span> element to each matched string.<\/span><\/li>\n<li>A class attribute is attached with the <span> element which can be used to specify the highlight color with CSS.<\/span><\/li>\n<li>The <b>highlightWords()<\/b> function accepts two parameters,\n<ul>\n<li><code>$text<\/code> &#8211; The content to search and replace.<\/li>\n<li><code>$word<\/code> &#8211; The string to search for.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre><span style=\"color: #FF8000\">\/\/&nbsp;Highlight&nbsp;words&nbsp;in&nbsp;text\n<\/span><span style=\"color: #007700\">function&nbsp;<\/span><span style=\"color: #0000BB\">highlightWords<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$text<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$word<\/span><span style=\"color: #007700\">){\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$text&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">preg_replace<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'#'<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">preg_quote<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$word<\/span><span style=\"color: #007700\">)&nbsp;.<\/span><span style=\"color: #DD0000\">'#i'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;span&nbsp;class=\"hlw\"&gt;\\\\0&lt;\/span&gt;'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$text<\/span><span style=\"color: #007700\">);\n&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">$text<\/span><span style=\"color: #007700\">;\n}<\/span><\/pre>\n<p>In the example code, we will fetch the posts data from the database and listed on the web page. Based on the search, the records will be filtered and the search term will be highlighted in the search results.<\/p>\n<h2>Create Database Table<\/h2>\n<p>For this example, we will create a posts table with some basic fields in the MySQL database. The <code>posts<\/code> table holds the records which will be searched and highlighted.<\/p>\n<pre style=\"color: rgb(110, 107, 94);\"><span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">CREATE<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">TABLE<\/span> <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">`posts`<\/span> (\n <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">`id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(182, 86, 17);\">int<\/span>(<span class=\"hljs-number\" style=\"color: rgb(182, 86, 17);\">11<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(182, 86, 17);\">NULL<\/span> AUTO_INCREMENT,\n <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">`title`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(182, 86, 17);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(182, 86, 17);\">255<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(182, 86, 17);\">NULL<\/span>,\n <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">`content`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(182, 86, 17);\">text<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(182, 86, 17);\">NULL<\/span>,\n <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">`created`<\/span> datetime <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(182, 86, 17);\">NULL<\/span>,\n <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">`modified`<\/span> datetime <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(182, 86, 17);\">NULL<\/span>,\n PRIMARY <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">KEY<\/span> (<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">`id`<\/span>)\n) <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">ENGINE<\/span>=<span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">InnoDB<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">DEFAULT<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">CHARSET<\/span>=utf8 <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">COLLATE<\/span>=utf8_unicode_ci;<\/pre>\n<h2>Database Configuration (dbConfig.php)<\/h2>\n<p>The following code is used to connect the database using PHP and MySQL. Specify the database host (<code>$dbHost<\/code>), username (<code>$dbUsername<\/code>), password (<code>$dbPassword<\/code>), and name (<code>$dbName<\/code>) as per your database credentials.<\/p>\n<pre><span style=\"color: #0000BB\">&lt;?php\n<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Database&nbsp;configuration\n<\/span><span style=\"color: #0000BB\">$dbHost&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"localhost\"<\/span><span style=\"color: #007700\">;\n<\/span><span style=\"color: #0000BB\">$dbUsername&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"root\"<\/span><span style=\"color: #007700\">;\n<\/span><span style=\"color: #0000BB\">$dbPassword&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"root\"<\/span><span style=\"color: #007700\">;\n<\/span><span style=\"color: #0000BB\">$dbName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"codexworld\"<\/span><span style=\"color: #007700\">;\n\n<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Create&nbsp;database&nbsp;connection\n<\/span><span style=\"color: #0000BB\">$db&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;new&nbsp;<\/span><span style=\"color: #0000BB\">mysqli<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$dbHost<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$dbUsername<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$dbPassword<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$dbName<\/span><span style=\"color: #007700\">);\n\n<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Check&nbsp;connection\n<\/span><span style=\"color: #007700\">if&nbsp;(<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">connect_error<\/span><span style=\"color: #007700\">)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;die(<\/span><span style=\"color: #DD0000\">\"Connection&nbsp;failed:&nbsp;\"&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">connect_error<\/span><span style=\"color: #007700\">);\n}<\/span><\/pre>\n<h2>Highlight Keywords in Search Results<\/h2>\n<p>Initially, all the records are fetched from the database and listed on the web page. Based on the search keyword, the words are highlighted in the search list.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>An HTML form is provided to filter the records based on the keywords.<\/li>\n<li>When the user search records by the keyword,\n<ul class=\"step_list\">\n<li>The WHERE clause is used with LIKE operator to filter the records by search term.<\/li>\n<li>Before displaying the search results, the <code>highlightWords()<\/code> function is used to add the highlighting class in the matched words.<\/li>\n<\/ul>\n<\/li>\n<li>Once the keywords are wrapped with the highlighting element in the search result, the attached class is used to highlight the string with CSS.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php\n<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Include&nbsp;the&nbsp;database&nbsp;config&nbsp;file\n<\/span><span style=\"color: #007700\">require_once&nbsp;<\/span><span style=\"color: #DD0000\">'dbConfig.php'<\/span><span style=\"color: #007700\">;\n\n<\/span><span style=\"color: #FF8000\">\/\/&nbsp;If&nbsp;the&nbsp;search&nbsp;form&nbsp;is&nbsp;submitted\n<\/span><span style=\"color: #0000BB\">$searchKeyword&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$whrSQL&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">''<\/span><span style=\"color: #007700\">;\nif(isset(<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'searchSubmit'<\/span><span style=\"color: #007700\">])){\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$searchKeyword&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'keyword'<\/span><span style=\"color: #007700\">];\n&nbsp;&nbsp;&nbsp;&nbsp;if(!empty(<\/span><span style=\"color: #0000BB\">$searchKeyword<\/span><span style=\"color: #007700\">)){\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;SQL&nbsp;query&nbsp;to&nbsp;filter&nbsp;records&nbsp;based&nbsp;on&nbsp;the&nbsp;search&nbsp;term\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$whrSQL&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"WHERE&nbsp;(title&nbsp;LIKE&nbsp;'%\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$searchKeyword<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"%'&nbsp;OR&nbsp;content&nbsp;LIKE&nbsp;'%\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$searchKeyword<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"%')\"<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;}\n}\n\n<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Get&nbsp;matched&nbsp;records&nbsp;from&nbsp;the&nbsp;database\n<\/span><span style=\"color: #0000BB\">$result&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">query<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"SELECT&nbsp;*&nbsp;FROM&nbsp;posts&nbsp;<\/span><span style=\"color: #0000BB\">$whrSQL<\/span><span style=\"color: #DD0000\">&nbsp;ORDER&nbsp;BY&nbsp;id&nbsp;DESC\"<\/span><span style=\"color: #007700\">);\n\n<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Highlight&nbsp;words&nbsp;in&nbsp;text\n<\/span><span style=\"color: #007700\">function&nbsp;<\/span><span style=\"color: #0000BB\">highlightWords<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$text<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$word<\/span><span style=\"color: #007700\">){\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$text&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">preg_replace<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'#'<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">preg_quote<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$word<\/span><span style=\"color: #007700\">)&nbsp;.<\/span><span style=\"color: #DD0000\">'#i'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;span&nbsp;class=\"hlw\"&gt;\\\\0&lt;\/span&gt;'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$text<\/span><span style=\"color: #007700\">);\n&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">$text<\/span><span style=\"color: #007700\">;\n}\n<\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n<pre style=\"color: rgb(95, 94, 78);\"><span class=\"hljs-comment\" style=\"color: rgb(108, 107, 90);\">&lt;!-- Search form --&gt;<\/span>\n<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">form<\/span> <span class=\"hljs-attr\">method<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"post\"<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"input-group\"<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">input<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"text\"<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"keyword\"<\/span> <span class=\"hljs-attr\">value<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$searchKeyword<\/span><span style=\"color: #007700\">;&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\"<\/span> <span class=\"hljs-attr\">placeholder<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"Search by keyword...\"<\/span> &gt;<\/span>\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">input<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"submit\"<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"searchSubmit\"<\/span> <span class=\"hljs-attr\">value<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"Search\"<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span>\n<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">form<\/span>&gt;<\/span><\/pre>\n<pre><span class=\"hljs-comment\" style=\"color: rgb(108, 107, 90);\">&lt;!-- Search results --&gt;<\/span>\n<span style=\"color: #0000BB\">&lt;?php\n<\/span><span style=\"color: #007700\">if(<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">num_rows&nbsp;<\/span><span style=\"color: #007700\">&gt;&nbsp;<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">){\n&nbsp;&nbsp;&nbsp;&nbsp;while(<\/span><span style=\"color: #0000BB\">$row&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">fetch_assoc<\/span><span style=\"color: #007700\">()){\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$title&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;!empty(<\/span><span style=\"color: #0000BB\">$searchKeyword<\/span><span style=\"color: #007700\">)?<\/span><span style=\"color: #0000BB\">highlightWords<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'title'<\/span><span style=\"color: #007700\">],&nbsp;<\/span><span style=\"color: #0000BB\">$searchKeyword<\/span><span style=\"color: #007700\">):<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'title'<\/span><span style=\"color: #007700\">];\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$contnet&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;!empty(<\/span><span style=\"color: #0000BB\">$searchKeyword<\/span><span style=\"color: #007700\">)?<\/span><span style=\"color: #0000BB\">highlightWords<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'content'<\/span><span style=\"color: #007700\">],&nbsp;<\/span><span style=\"color: #0000BB\">$searchKeyword<\/span><span style=\"color: #007700\">):<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'content'<\/span><span style=\"color: #007700\">];\n<\/span><span style=\"color: #0000BB\">?&gt;\n<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"list-item\"<\/span>&gt;<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h4<\/span>&gt;<\/span><span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$title<\/span><span style=\"color: #007700\">;&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">\/h4<\/span>&gt;<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$contnet<\/span><span style=\"color: #007700\">;&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">\/p<\/span>&gt;\n&lt;\/div&gt;<\/span>\n<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">}&nbsp;}else{&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;\n<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>No post(s) found...<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\n<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">}&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n<h2>Highlight Keywords without CSS<\/h2>\n<p>You can use inline CSS to highlight the words in the text without using a CSS class. In this case, the <b>highlightWords()<\/b> will be modified like the following.<\/p>\n<pre><span style=\"color: #007700\">function&nbsp;<\/span><span style=\"color: #0000BB\">highlightWords<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$text<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$word<\/span><span style=\"color: #007700\">){\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$text&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">preg_replace<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'#'<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">preg_quote<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$word<\/span><span style=\"color: #007700\">)&nbsp;.<\/span><span style=\"color: #DD0000\">'#i'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;span&nbsp;style=\"background-color:&nbsp;#F9F902;\"&gt;\\\\0&lt;\/span&gt;'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$text<\/span><span style=\"color: #007700\">);\n&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">$text<\/span><span style=\"color: #007700\">;\n}<\/span><\/pre>\n<p class=\"seeAlso\"><span><\/span><a href=\"https:\/\/www.codexworld.com\/php-crud-operations-with-search-and-pagination\/\">PHP CRUD Operations with Search and Pagination<\/a><\/p>\n<h2>Conclusion<\/h2>\n<p>Our <b>highlightWords()<\/b> class will work the both text and HTML content. Using the example code, you can highlight keywords in the search results with HTML content. This <b>search highlight<\/b> functionality will be very useful for the list of the data management section. Also, you can easily enhance our highlight search keyword functionality using PHP and MySQL.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Search functionality is very useful for the data list. It helps to find the relevant records quickly from the database. Search term highlighting feature makes the search functionality user-friendly. Highlight keyword helps the user to <\/p>\n","protected":false},"author":1,"featured_media":3931,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[327,19,14,211],"class_list":["post-3927","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-highlight","tag-mysql","tag-php","tag-search","cat-4-id","has_thumb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Highlight Keyword in Search Results with PHP and MySQL - CodexWorld<\/title>\n<meta name=\"description\" content=\"Highlight search keyword - Keyword highlight in search results with PHP. PHP script to search in MySQL database and highlight search terms in the text. Use highlightWords() function to highlight the words in text.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codexworld.com\/highlight-keyword-in-search-results-php-mysql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Highlight Keyword in Search Results with PHP and MySQL - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"Highlight search keyword - Keyword highlight in search results with PHP. PHP script to search in MySQL database and highlight search terms in the text. Use highlightWords() function to highlight the words in text.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/highlight-keyword-in-search-results-php-mysql\/\" \/>\n<meta property=\"og:site_name\" content=\"CodexWorld\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-18T20:24:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-18T20:32:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/03\/highlight-keyword-term-in-search-results-php-mysql-codexworld.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1366\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"CodexWorld\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codexworldblog\" \/>\n<meta name=\"twitter:site\" content=\"@codexworldweb\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"CodexWorld\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/highlight-keyword-in-search-results-php-mysql\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/highlight-keyword-in-search-results-php-mysql\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"Highlight Keyword in Search Results with PHP and MySQL\",\"datePublished\":\"2019-03-18T20:24:20+00:00\",\"dateModified\":\"2019-03-18T20:32:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/highlight-keyword-in-search-results-php-mysql\\\/\"},\"wordCount\":481,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/highlight-keyword-in-search-results-php-mysql\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/highlight-keyword-term-in-search-results-php-mysql-codexworld.png\",\"keywords\":[\"Highlight\",\"MySQL\",\"PHP\",\"Search\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/highlight-keyword-in-search-results-php-mysql\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/highlight-keyword-in-search-results-php-mysql\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/highlight-keyword-in-search-results-php-mysql\\\/\",\"name\":\"Highlight Keyword in Search Results with PHP and MySQL - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/highlight-keyword-in-search-results-php-mysql\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/highlight-keyword-in-search-results-php-mysql\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/highlight-keyword-term-in-search-results-php-mysql-codexworld.png\",\"datePublished\":\"2019-03-18T20:24:20+00:00\",\"dateModified\":\"2019-03-18T20:32:43+00:00\",\"description\":\"Highlight search keyword - Keyword highlight in search results with PHP. PHP script to search in MySQL database and highlight search terms in the text. Use highlightWords() function to highlight the words in text.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/highlight-keyword-in-search-results-php-mysql\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/highlight-keyword-in-search-results-php-mysql\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/highlight-keyword-in-search-results-php-mysql\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/highlight-keyword-term-in-search-results-php-mysql-codexworld.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/highlight-keyword-term-in-search-results-php-mysql-codexworld.png\",\"width\":1366,\"height\":768,\"caption\":\"highlight-keyword-term-in-search-results-php-mysql-codexworld\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/highlight-keyword-in-search-results-php-mysql\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Highlight Keyword in Search Results with PHP and MySQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"name\":\"CodexWorld\",\"description\":\"Web &amp; Mobile App Development Company\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.codexworld.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\",\"name\":\"CodexWorld\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"width\":200,\"height\":19,\"caption\":\"CodexWorld\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldweb\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/codexworld\",\"https:\\\/\\\/www.youtube.com\\\/codexworld\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\",\"name\":\"CodexWorld\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"caption\":\"CodexWorld\"},\"description\":\"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.\",\"sameAs\":[\"http:\\\/\\\/www.codexworld.com\",\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldblog\"],\"url\":\"https:\\\/\\\/www.codexworld.com\\\/author\\\/nitya192265\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Highlight Keyword in Search Results with PHP and MySQL - CodexWorld","description":"Highlight search keyword - Keyword highlight in search results with PHP. PHP script to search in MySQL database and highlight search terms in the text. Use highlightWords() function to highlight the words in text.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.codexworld.com\/highlight-keyword-in-search-results-php-mysql\/","og_locale":"en_US","og_type":"article","og_title":"Highlight Keyword in Search Results with PHP and MySQL - CodexWorld","og_description":"Highlight search keyword - Keyword highlight in search results with PHP. PHP script to search in MySQL database and highlight search terms in the text. Use highlightWords() function to highlight the words in text.","og_url":"https:\/\/www.codexworld.com\/highlight-keyword-in-search-results-php-mysql\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2019-03-18T20:24:20+00:00","article_modified_time":"2019-03-18T20:32:43+00:00","og_image":[{"width":1366,"height":768,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/03\/highlight-keyword-term-in-search-results-php-mysql-codexworld.png","type":"image\/png"}],"author":"CodexWorld","twitter_card":"summary_large_image","twitter_creator":"@codexworldblog","twitter_site":"@codexworldweb","twitter_misc":{"Written by":"CodexWorld","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codexworld.com\/highlight-keyword-in-search-results-php-mysql\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/highlight-keyword-in-search-results-php-mysql\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"Highlight Keyword in Search Results with PHP and MySQL","datePublished":"2019-03-18T20:24:20+00:00","dateModified":"2019-03-18T20:32:43+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/highlight-keyword-in-search-results-php-mysql\/"},"wordCount":481,"commentCount":3,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/highlight-keyword-in-search-results-php-mysql\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/03\/highlight-keyword-term-in-search-results-php-mysql-codexworld.png","keywords":["Highlight","MySQL","PHP","Search"],"articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codexworld.com\/highlight-keyword-in-search-results-php-mysql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/highlight-keyword-in-search-results-php-mysql\/","url":"https:\/\/www.codexworld.com\/highlight-keyword-in-search-results-php-mysql\/","name":"Highlight Keyword in Search Results with PHP and MySQL - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/highlight-keyword-in-search-results-php-mysql\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/highlight-keyword-in-search-results-php-mysql\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/03\/highlight-keyword-term-in-search-results-php-mysql-codexworld.png","datePublished":"2019-03-18T20:24:20+00:00","dateModified":"2019-03-18T20:32:43+00:00","description":"Highlight search keyword - Keyword highlight in search results with PHP. PHP script to search in MySQL database and highlight search terms in the text. Use highlightWords() function to highlight the words in text.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/highlight-keyword-in-search-results-php-mysql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/highlight-keyword-in-search-results-php-mysql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/highlight-keyword-in-search-results-php-mysql\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/03\/highlight-keyword-term-in-search-results-php-mysql-codexworld.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/03\/highlight-keyword-term-in-search-results-php-mysql-codexworld.png","width":1366,"height":768,"caption":"highlight-keyword-term-in-search-results-php-mysql-codexworld"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/highlight-keyword-in-search-results-php-mysql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"Highlight Keyword in Search Results with PHP and MySQL"}]},{"@type":"WebSite","@id":"https:\/\/www.codexworld.com\/#website","url":"https:\/\/www.codexworld.com\/","name":"CodexWorld","description":"Web &amp; Mobile App Development Company","publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codexworld.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codexworld.com\/#organization","name":"CodexWorld","url":"https:\/\/www.codexworld.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","width":200,"height":19,"caption":"CodexWorld"},"image":{"@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldweb","https:\/\/www.linkedin.com\/company\/codexworld","https:\/\/www.youtube.com\/codexworld"]},{"@type":"Person","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0","name":"CodexWorld","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","caption":"CodexWorld"},"description":"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.","sameAs":["http:\/\/www.codexworld.com","https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldblog"],"url":"https:\/\/www.codexworld.com\/author\/nitya192265\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/03\/highlight-keyword-term-in-search-results-php-mysql-codexworld.png","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-11l","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/3927","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/comments?post=3927"}],"version-history":[{"count":4,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/3927\/revisions"}],"predecessor-version":[{"id":3933,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/3927\/revisions\/3933"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/3931"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=3927"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=3927"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=3927"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}