Using split function to split a string
$headline = "a b c d e"; foreach (split " ", $headline) { print ucfirst, " "; }