note 127761 added to language.operators.array

From: Date: Wed, 19 Oct 2022 09:32:42 +0000
Subject: note 127761 added to language.operators.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-219712@lists.php.net to get a copy of this message
Merge two arrays and retain only unique values. Append values from second array. Do not care about keys. <?php $array1 = [ 0 => 'apple', 1 => 'orange', 2 => 'pear', ]; $array2 = [ 0 => 'melon', 1 => 'orange', 2 => 'banana', ]; $result = array_keys( array_flip($array1) + array_flip($array2) ); ?> Result: [ [0] => "apple", [1] => "orange", [2] => "pear", [3] => "melon", [4] => "banana", } ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.159.161 (proxied: 81.223.3.226) ---- Manual Page -- https://php.net/manual/en/language.operators.array.php Edit -- https://main.php.net/note/edit/127761 Del: integrated -- https://main.php.net/note/delete/127761/integrated Del: useless -- https://main.php.net/note/delete/127761/useless Del: bad code -- https://main.php.net/note/delete/127761/bad+code Del: spam -- https://main.php.net/note/delete/127761/spam Del: non-english -- https://main.php.net/note/delete/127761/non-english Del: in docs -- https://main.php.net/note/delete/127761/in+docs Del: other reasons-- https://main.php.net/note/delete/127761 Reject -- https://main.php.net/note/reject/127761 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#219712) next »