note 123976 added to function.array-intersect
| From: | Ehsan.Chavoshi.com@php.net | Date: | Sat, 22 Jun 2019 17:15:45 +0000 |
| Subject: | note 123976 added to function.array-intersect | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-211335@lists.php.net to get a copy of this message | ||
I wrote this function to recursively replace array keys with array values (flip) and fill values
with defined value. it can be used for recursive array intersect functions .
<?php
function array_values_to_keys_r($array, $fill_value = null)
{
$flipped = [];
foreach ($array as $key => $value) {
if (is_array($value)) {
$flipped [$key] = array_values_to_keys_r($value);
} else {
$flipped [$value] = $fill_value;
}
}
return $flipped;
}
?>
----
Server IP: 208.43.231.9
Probable Submitter: 185.85.3.195 (proxied: 5.219.143.107)
----
Manual Page -- http://php.net/manual/en/function.array-intersect.php
Edit -- https://master.php.net/note/edit/123976
Del: integrated -- https://master.php.net/note/delete/123976/integrated
Del: useless -- https://master.php.net/note/delete/123976/useless
Del: bad code -- https://master.php.net/note/delete/123976/bad+code
Del: spam -- https://master.php.net/note/delete/123976/spam
Del: non-english -- https://master.php.net/note/delete/123976/non-english
Del: in docs -- https://master.php.net/note/delete/123976/in+docs
Del: other reasons-- https://master.php.net/note/delete/123976
Reject -- https://master.php.net/note/reject/123976
Search -- https://master.php.net/manage/user-notes.php