Variable $name
(string) gives something like (possible values):
"Elton John"
"2012"
" George Bush"
" Julia"
"Marry III Great"
Want to catch the first letter of $name
and add it to $letter
variable.
It's important how many words (divided with spaces " ") the string has:
If there is just one word, set
$letter
to the first letter of the first word.If there is more than one word, set
$letter
to the first letter of the second word.If
$name
is empty, set$letter
to'undefined'
.
Thanks.