note 128266 added to function.array-key-exists

From: Date: Wed, 01 Mar 2023 15:18:56 +0000
Subject: note 128266 added to function.array-key-exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-220223@lists.php.net to get a copy of this message
When you want to check multiple array keys: <?php $array = []; $array['a'] = ''; $array['b'] = ''; $array['c'] = ''; $array['d'] = ''; $array['e'] = ''; // all given keys a,b,c exists in the supplied array var_dump(array_keys_exists(['a','b','c'], $array)); // bool(true) function array_keys_exists(array $keys, array $array): bool { $diff = array_diff_key(array_flip($keys), $array); return count($diff) === 0; } ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.13.130 (proxied: 2a02:58:14d:5100:c428:2fbb:6274:e049) ---- Manual Page -- https://php.net/manual/en/function.array-key-exists.php Edit -- https://main.php.net/note/edit/128266 Del: integrated -- https://main.php.net/note/delete/128266/integrated Del: useless -- https://main.php.net/note/delete/128266/useless Del: bad code -- https://main.php.net/note/delete/128266/bad+code Del: spam -- https://main.php.net/note/delete/128266/spam Del: non-english -- https://main.php.net/note/delete/128266/non-english Del: in docs -- https://main.php.net/note/delete/128266/in+docs Del: other reasons-- https://main.php.net/note/delete/128266 Reject -- https://main.php.net/note/reject/128266 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#220223) next »