note 128574 added to function.array-key-exists

From: Date: Sat, 27 May 2023 15:30:07 +0000
Subject: note 128574 added to function.array-key-exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-220529@lists.php.net to get a copy of this message
If you want to use the array_key_exists function, you must write your array as key => value (associative array). Otherwise, the array_key_exists function will return false. --------------------------------------------------------------------------------------- <?php beautyWorks = [$this->laminate, $this->composite, $this->scaling]; array_key_exists('laminate', $beautyWorks); // return false! beautyWorks = [$this->laminate => 'laminate', $this->composite, $this->scaling]; array_key_exists('laminate', $beautyWorks); // return true! ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.13.130 (proxied: 50.7.87.84) ---- Manual Page -- https://php.net/manual/en/function.array-key-exists.php Edit -- https://main.php.net/note/edit/128574 Del: integrated -- https://main.php.net/note/delete/128574/integrated Del: useless -- https://main.php.net/note/delete/128574/useless Del: bad code -- https://main.php.net/note/delete/128574/bad+code Del: spam -- https://main.php.net/note/delete/128574/spam Del: non-english -- https://main.php.net/note/delete/128574/non-english Del: in docs -- https://main.php.net/note/delete/128574/in+docs Del: other reasons-- https://main.php.net/note/delete/128574 Reject -- https://main.php.net/note/reject/128574 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#220529) next »