{"id":24,"date":"2024-05-29T03:24:21","date_gmt":"2024-05-29T03:24:21","guid":{"rendered":"https:\/\/codingindialab.com\/blog\/?p=24"},"modified":"2026-04-06T05:00:11","modified_gmt":"2026-04-06T05:00:11","slug":"hide-the-same-words-in-two-different-strings-using-php","status":"publish","type":"post","link":"https:\/\/codingindialab.com\/blog\/hide-the-same-words-in-two-different-strings-using-php\/","title":{"rendered":"Hide The Same Words In Two Different Strings Using PHP"},"content":{"rendered":"<h2>How to Create ?<\/h2>\n<p>You need to create a function to hide the word from two different strings, You can name the function as you like.<\/p>\n<p>We will create two different variables in which we will pass the words and this function will give you the same word after removing it as you can see in the example given below:<\/p>\n<p><strong>Example Code:<\/strong><\/p>\n<p>&lt;?php<br \/>\nfunction hideCommonWords($string1, $string2) {<br \/>\n$array1 = explode(&#8216; &#8216;, $string1);<br \/>\n$array2 = explode(&#8216; &#8216;, $string2);<br \/>\n\/\/ Find common words and remove them from both arrays<br \/>\n$commonWords = array_intersect($array1, $array2);<br \/>\n$array1 = array_diff($array1, $commonWords);<br \/>\n$array2 = array_diff($array2, $commonWords);<br \/>\n\/\/ Reconstruct strings<br \/>\n$newString1 = implode(&#8216; &#8216;, $array1);<br \/>\n$newString2 = implode(&#8216; &#8216;, $array2);<br \/>\nreturn [$newString1, $newString2];<br \/>\n}<br \/>\n\/\/ Example usage<br \/>\n$string1 = &#8220;Bajaj&#8221;;<br \/>\n$string2 = &#8220;Bajaj Dominar 250&#8221;;<br \/>\nlist($newString1, $newString2) = hideCommonWords($string1, $string2);<br \/>\necho &#8220;String 2 without common words: $newString2\\n&#8221;;<br \/>\n?&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Create ? You need to create a function to hide the word from&#8230;<\/p>\n","protected":false},"author":1,"featured_media":230,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-24","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Hide The Same Words In Two Different Strings Using PHP<\/title>\n<meta name=\"description\" content=\"By using PHP you can extract the word from two different strings. its very important when we remove the same words in the content.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codingindialab.com\/blog\/hide-the-same-words-in-two-different-strings-using-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hide The Same Words In Two Different Strings Using PHP\" \/>\n<meta property=\"og:description\" content=\"By using PHP you can extract the word from two different strings. its very important when we remove the same words in the content.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codingindialab.com\/blog\/hide-the-same-words-in-two-different-strings-using-php\/\" \/>\n<meta property=\"og:site_name\" content=\"Buy Tools - Coding India Lab\" \/>\n<meta property=\"article:published_time\" content=\"2024-05-29T03:24:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-06T05:00:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codingindialab.com\/blog\/wp-content\/uploads\/2024\/05\/hide-the-same-words-1.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"500\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/hide-the-same-words-in-two-different-strings-using-php\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/hide-the-same-words-in-two-different-strings-using-php\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/#\\\/schema\\\/person\\\/94a2d1f0e37a9a178ed9cd0a3aa7f3ce\"},\"headline\":\"Hide The Same Words In Two Different Strings Using PHP\",\"datePublished\":\"2024-05-29T03:24:21+00:00\",\"dateModified\":\"2026-04-06T05:00:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/hide-the-same-words-in-two-different-strings-using-php\\\/\"},\"wordCount\":139,\"image\":{\"@id\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/hide-the-same-words-in-two-different-strings-using-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/codingindialab.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/hide-the-same-words-1.webp?fit=1920%2C500&ssl=1\",\"articleSection\":[\"php\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/hide-the-same-words-in-two-different-strings-using-php\\\/\",\"url\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/hide-the-same-words-in-two-different-strings-using-php\\\/\",\"name\":\"Hide The Same Words In Two Different Strings Using PHP\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/hide-the-same-words-in-two-different-strings-using-php\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/hide-the-same-words-in-two-different-strings-using-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/codingindialab.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/hide-the-same-words-1.webp?fit=1920%2C500&ssl=1\",\"datePublished\":\"2024-05-29T03:24:21+00:00\",\"dateModified\":\"2026-04-06T05:00:11+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/#\\\/schema\\\/person\\\/94a2d1f0e37a9a178ed9cd0a3aa7f3ce\"},\"description\":\"By using PHP you can extract the word from two different strings. its very important when we remove the same words in the content.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/hide-the-same-words-in-two-different-strings-using-php\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/codingindialab.com\\\/blog\\\/hide-the-same-words-in-two-different-strings-using-php\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/hide-the-same-words-in-two-different-strings-using-php\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/codingindialab.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/hide-the-same-words-1.webp?fit=1920%2C500&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/codingindialab.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/hide-the-same-words-1.webp?fit=1920%2C500&ssl=1\",\"width\":1920,\"height\":500,\"caption\":\"Hide The Same Words In Two Different Strings Using PHP\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/hide-the-same-words-in-two-different-strings-using-php\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hide The Same Words In Two Different Strings Using PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/\",\"name\":\"Coding India\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/#\\\/schema\\\/person\\\/94a2d1f0e37a9a178ed9cd0a3aa7f3ce\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cd5a9365f6d133d34466f8b64e07682be41ad59e15e64b8bda642df41823202e?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cd5a9365f6d133d34466f8b64e07682be41ad59e15e64b8bda642df41823202e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cd5a9365f6d133d34466f8b64e07682be41ad59e15e64b8bda642df41823202e?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\\\/\\\/codingindialab.com\\\/blog\"],\"url\":\"https:\\\/\\\/codingindialab.com\\\/blog\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Hide The Same Words In Two Different Strings Using PHP","description":"By using PHP you can extract the word from two different strings. its very important when we remove the same words in the content.","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:\/\/codingindialab.com\/blog\/hide-the-same-words-in-two-different-strings-using-php\/","og_locale":"en_US","og_type":"article","og_title":"Hide The Same Words In Two Different Strings Using PHP","og_description":"By using PHP you can extract the word from two different strings. its very important when we remove the same words in the content.","og_url":"https:\/\/codingindialab.com\/blog\/hide-the-same-words-in-two-different-strings-using-php\/","og_site_name":"Buy Tools - Coding India Lab","article_published_time":"2024-05-29T03:24:21+00:00","article_modified_time":"2026-04-06T05:00:11+00:00","og_image":[{"width":1920,"height":500,"url":"https:\/\/codingindialab.com\/blog\/wp-content\/uploads\/2024\/05\/hide-the-same-words-1.webp","type":"image\/webp"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/codingindialab.com\/blog\/hide-the-same-words-in-two-different-strings-using-php\/#article","isPartOf":{"@id":"https:\/\/codingindialab.com\/blog\/hide-the-same-words-in-two-different-strings-using-php\/"},"author":{"name":"admin","@id":"https:\/\/codingindialab.com\/blog\/#\/schema\/person\/94a2d1f0e37a9a178ed9cd0a3aa7f3ce"},"headline":"Hide The Same Words In Two Different Strings Using PHP","datePublished":"2024-05-29T03:24:21+00:00","dateModified":"2026-04-06T05:00:11+00:00","mainEntityOfPage":{"@id":"https:\/\/codingindialab.com\/blog\/hide-the-same-words-in-two-different-strings-using-php\/"},"wordCount":139,"image":{"@id":"https:\/\/codingindialab.com\/blog\/hide-the-same-words-in-two-different-strings-using-php\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/codingindialab.com\/blog\/wp-content\/uploads\/2024\/05\/hide-the-same-words-1.webp?fit=1920%2C500&ssl=1","articleSection":["php"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/codingindialab.com\/blog\/hide-the-same-words-in-two-different-strings-using-php\/","url":"https:\/\/codingindialab.com\/blog\/hide-the-same-words-in-two-different-strings-using-php\/","name":"Hide The Same Words In Two Different Strings Using PHP","isPartOf":{"@id":"https:\/\/codingindialab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/codingindialab.com\/blog\/hide-the-same-words-in-two-different-strings-using-php\/#primaryimage"},"image":{"@id":"https:\/\/codingindialab.com\/blog\/hide-the-same-words-in-two-different-strings-using-php\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/codingindialab.com\/blog\/wp-content\/uploads\/2024\/05\/hide-the-same-words-1.webp?fit=1920%2C500&ssl=1","datePublished":"2024-05-29T03:24:21+00:00","dateModified":"2026-04-06T05:00:11+00:00","author":{"@id":"https:\/\/codingindialab.com\/blog\/#\/schema\/person\/94a2d1f0e37a9a178ed9cd0a3aa7f3ce"},"description":"By using PHP you can extract the word from two different strings. its very important when we remove the same words in the content.","breadcrumb":{"@id":"https:\/\/codingindialab.com\/blog\/hide-the-same-words-in-two-different-strings-using-php\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codingindialab.com\/blog\/hide-the-same-words-in-two-different-strings-using-php\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codingindialab.com\/blog\/hide-the-same-words-in-two-different-strings-using-php\/#primaryimage","url":"https:\/\/i0.wp.com\/codingindialab.com\/blog\/wp-content\/uploads\/2024\/05\/hide-the-same-words-1.webp?fit=1920%2C500&ssl=1","contentUrl":"https:\/\/i0.wp.com\/codingindialab.com\/blog\/wp-content\/uploads\/2024\/05\/hide-the-same-words-1.webp?fit=1920%2C500&ssl=1","width":1920,"height":500,"caption":"Hide The Same Words In Two Different Strings Using PHP"},{"@type":"BreadcrumbList","@id":"https:\/\/codingindialab.com\/blog\/hide-the-same-words-in-two-different-strings-using-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codingindialab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Hide The Same Words In Two Different Strings Using PHP"}]},{"@type":"WebSite","@id":"https:\/\/codingindialab.com\/blog\/#website","url":"https:\/\/codingindialab.com\/blog\/","name":"Coding India","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codingindialab.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/codingindialab.com\/blog\/#\/schema\/person\/94a2d1f0e37a9a178ed9cd0a3aa7f3ce","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cd5a9365f6d133d34466f8b64e07682be41ad59e15e64b8bda642df41823202e?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cd5a9365f6d133d34466f8b64e07682be41ad59e15e64b8bda642df41823202e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cd5a9365f6d133d34466f8b64e07682be41ad59e15e64b8bda642df41823202e?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/codingindialab.com\/blog"],"url":"https:\/\/codingindialab.com\/blog\/author\/admin\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/codingindialab.com\/blog\/wp-content\/uploads\/2024\/05\/hide-the-same-words-1.webp?fit=1920%2C500&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/codingindialab.com\/blog\/wp-json\/wp\/v2\/posts\/24","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codingindialab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codingindialab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codingindialab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codingindialab.com\/blog\/wp-json\/wp\/v2\/comments?post=24"}],"version-history":[{"count":1,"href":"https:\/\/codingindialab.com\/blog\/wp-json\/wp\/v2\/posts\/24\/revisions"}],"predecessor-version":[{"id":231,"href":"https:\/\/codingindialab.com\/blog\/wp-json\/wp\/v2\/posts\/24\/revisions\/231"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codingindialab.com\/blog\/wp-json\/wp\/v2\/media\/230"}],"wp:attachment":[{"href":"https:\/\/codingindialab.com\/blog\/wp-json\/wp\/v2\/media?parent=24"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codingindialab.com\/blog\/wp-json\/wp\/v2\/categories?post=24"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codingindialab.com\/blog\/wp-json\/wp\/v2\/tags?post=24"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}