note 86474 added to function.array-key-exists

From: Date: Tue, 21 Oct 2008 15:13:50 +0000
Subject: note 86474 added to function.array-key-exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-145540@lists.php.net to get a copy of this message
Something to keep in mind is that array_key_exists is case sensitive. So two things I'd like to say: 1. Could there be an additional option added on to the array_key_exists command so you can specify the case to be insensitive? 2. Here is how you can do this test in one command: if( preg_match("/<key>/i", join(",", array_keys(<array>))) ){ <Do something> } But it would be a lot nicer to just have an additional option on the array_key_exists. Like so: array_key_exists(<array>, ["i"] ); Ok - so why did this come up at all? I wrote a routine to convert any whacky UppERcAsE kind of lettering to just be lowercase letters. (ex: FgColorS becomes fgcolors and so forth.) So I never had to guess what the user was putting in to the program. There were two particular items (fgColors and bgColors) which I wanted to test against. If they were not supplied, my program would supply them. The above was the easiest way I could come up with to do this. :-) ---- Server IP: 208.69.120.35 Probable Submitter: 143.111.22.24 ---- Manual Page -- http://www.php.net/manual/en/function.array-key-exists.php Edit -- https://master.php.net/note/edit/86474 Del: integrated -- https://master.php.net/note/delete/86474/integrated Del: useless -- https://master.php.net/note/delete/86474/useless Del: bad code -- https://master.php.net/note/delete/86474/bad+code Del: spam -- https://master.php.net/note/delete/86474/spam Del: non-english -- https://master.php.net/note/delete/86474/non-english Del: in docs -- https://master.php.net/note/delete/86474/in+docs Del: other reasons-- https://master.php.net/note/delete/86474 Reject -- https://master.php.net/note/reject/86474 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#145540) next »