3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $names = array('Anderson','Beresford','Donovan','Amit','Graham'); $alphabet = array(); $previous_letter = ''; foreach($names as $value) { if($value[0] != $previous_letter) { $alphabet[] = $previous_letter = $value[0]; } } print_r($alphabet); ?>
based on VT0Rt
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
Array ( [0] => A [1] => B [2] => D [3] => A [4] => G )
Output for hhvm-3.10.0

Process exited with code 153.