note 126352 added to function.array-intersect-key

From: Date: Thu, 19 Aug 2021 11:38:52 +0000
Subject: note 126352 added to function.array-intersect-key
Groups: php.notes 
Request: Send a blank email to php-notes+get-216808@lists.php.net to get a copy of this message
Note that the order of the keys in the returned array is the same as the order of the keys in the source array. To sort by the second array, then you may do so through array_replace. <?php $array = array( 'two' => 'a', 'three' => 'b', 'one' => 'c', ); $keyswant = array( 'one' => '', 'three' => '', ); print_r(array_intersect_key(array_replace($keyswant, $array), $keyswant)); ?> Shows: Array ( [one] => c [three] => b ) Rather than: Array ( [three] => b [one] => c ) ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.242 (proxied: 178.79.161.164) ---- Manual Page -- https://php.net/manual/en/function.array-intersect-key.php Edit -- https://main.php.net/note/edit/126352 Del: integrated -- https://main.php.net/note/delete/126352/integrated Del: useless -- https://main.php.net/note/delete/126352/useless Del: bad code -- https://main.php.net/note/delete/126352/bad+code Del: spam -- https://main.php.net/note/delete/126352/spam Del: non-english -- https://main.php.net/note/delete/126352/non-english Del: in docs -- https://main.php.net/note/delete/126352/in+docs Del: other reasons-- https://main.php.net/note/delete/126352 Reject -- https://main.php.net/note/reject/126352 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#216808) next »