3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $names = array('Anderson','Beresford','Donovan','Emerson','Graham'); $alphabet = array(); $previous_letter = ''; foreach($names as $value) { if($value[0] != $previous_letter) { $alphabet[] = $previous_letter = $value[0]; } } ?>
based on VT0Rt
Output for 4.3.0 - 7.1.0