3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $clientContactName = "Annelie Sterling"; $split = preg_split('/ /', $clientContactName); if(count($split) >= 2) { //no point in trying to match if we don't have both a first and last name $firstname = trim(implode("", array_splice($split,0,1))); $lastname = trim(implode("",$split)); } echo $firstname; echo "\n"; echo $lastname;
Output for 4.3.0 - 7.2.0
Annelie Sterling