3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $mergeInfos = array( 2=>3 , 4=>3 ,3=>7 ,7=>7); $smallMergeInfos = array(3=>7); foreach ($mergeInfos as $key => $value) { if (array_key_exists($value , $smallMergeInfos)) { $mergeInfos[$key] = $smallMergeInfos[$value]; echo "$key" . "==>>" . "$smallMergeInfos[$value]" . "\n"; } } $campusIds = implode(',' , array_unique(array_values($mergeInfos))); $campus_address_ids = array(1,2,3,4,5,6,7); $campus_address_ids = str_replace(array_keys($mergeInfos) , array_values($mergeInfos) , $campus_address_ids); $campus_address_ids = implode(',' , array_unique($campus_address_ids)); echo $campus_address_ids; echo '32'-'5';
based on 5jaff
Output for 4.3.0 - 7.2.0
2==>>7 4==>>7 1,7,5,627