3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $first = array( 2, 3, 5, 7); $second = array(2, 3, 5, 23); $prime = "Prime Factors of 420:"; $scndprim = "Prime Factors of 690:"; foreach ($first as $key => $value) { if(in_array($value, $second)) { $prime .="<b>".$value."</b>,"; }else{ $prime .=$value.","; } // ========= for second array if(in_array($second[$key], $first)) { $scndprim .="<b>".$second[$key]."</b>,"; }else{ $scndprim .=$second[$key].","; } } print_r(trim($prime,',')); print_r(trim($scndprim,','));
Output for 4.3.0 - 5.6.25, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
Prime Factors of 420:<b>2</b>,<b>3</b>,<b>5</b>,7Prime Factors of 690:<b>2</b>,<b>3</b>,<b>5</b>,23