In that case you should do something like this:
<?php
function FirstLetter($words) {
if (!empty($words)) {
$result = '';
foreach (explode(' ', $words) as $word) {
$result .= $word[0];
}
return strtoupper($result);
} else {
return false;
}
}
$words = "some short sentence";
if (($info = FirstLetter($words)) === false) {
$info = 'Error';
}
header('Location: http://somesite.com?code=' . urlencode($info));
There is no need to construct an array when you can append to a string, and then strtoupper will do. Notice also that FirstLetter does not output anything; this job is left to the caller, along with the translation of the false value to whatever error code is deemed appropriate.
EDIT:
Come to think of it, you only need to call strtoupper once. It is also a mistake to output stuff before sending a header, and rather pointless for a location header. My example has been modified accordingly.