{"id":203,"date":"2017-01-15T08:53:26","date_gmt":"2017-01-15T08:53:26","guid":{"rendered":"http:\/\/rat32.com\/rat32\/?p=203"},"modified":"2017-01-15T08:53:26","modified_gmt":"2017-01-15T08:53:26","slug":"how-to-perform-case-insensitive-array-search-in-php","status":"publish","type":"post","link":"https:\/\/rat32.com\/rat32\/2017\/01\/15\/how-to-perform-case-insensitive-array-search-in-php\/","title":{"rendered":"How to perform case insensitive array search in php?"},"content":{"rendered":"<p>Searching is a usual and regular task in programming. Letters case sensitivity is a problematic in searching. Hence, both search string and array string should be converted into same case before searching. Otherwise searching would return the empty result. Here is how to do it:<\/p>\n<pre class=\"lang:php decode:true \" >$array = array(\"apple\",\"mango\",\"banana\");\r\n$searchString = \"Apple\";\r\narray_search(strtolower($searchString), array_map('strtolower', $array));<\/pre>\n<p>As shown above, search string is converted into lowercase and all the items of an array are converted to lowercase with <strong>array_map<\/strong> function and finally array_search is done. Alternatively, same can be done with converting search string and array into uppercase using strtoupper function.<\/p>\n<p>Hope, it helps. If helped, please do not forget to comment below. Thanks.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Searching is a usual and regular task in programming. Letters case sensitivity is a problematic in searching. Hence, both search string and array string should be converted into same case before searching. Otherwise searching&#46;&#46;&#46;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,3],"tags":[134,133,130,84,131,132],"class_list":["post-203","post","type-post","status-publish","format-standard","hentry","category-how-to","category-php","tag-array_map","tag-array_search","tag-insensitive-array-search","tag-php","tag-strtolower","tag-strtoupper"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/posts\/203"}],"collection":[{"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/comments?post=203"}],"version-history":[{"count":1,"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/posts\/203\/revisions"}],"predecessor-version":[{"id":204,"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/posts\/203\/revisions\/204"}],"wp:attachment":[{"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/media?parent=203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/categories?post=203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/tags?post=203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}