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 'm'-'a';
based on o6D5Y
Output for 7.1.0 - 7.2.0
2==>>7 4==>>7 1,7,5,6 Warning: A non-numeric value encountered in /in/5jaff on line 15 Warning: A non-numeric value encountered in /in/5jaff on line 15 0
Output for 4.3.0 - 7.0.20
2==>>7 4==>>7 1,7,5,60