Array to string
| From: | Erik J. Barzeski | Date: | Wed, 29 Nov 2000 17:16:51 +0000 |
| Subject: | Array to string | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-27836@lists.php.net to get a copy of this message | ||
Hi,
I've spent a few hours on a problem:
function find_first($fullname)
{
$char = 0;
do
{
$first[$char] = $fullname[$char];
$char++;
} while (($fullname[$char] != " ") && ($fullname[$char] != '\n')
&&
($char < 50));
return $first;
}
Basically, "$fullname" is a string. $fullname[$char] works fine, the
loop stops when the end of the first name is encountered, and in the case of
Joe Schmoe, "J" and "o" and "e" are the array elements.
Problem is, when I return $first at the end and echo it... It literally
becomes the string "Array." The same happens if I do:
$first .= "";
The variable $first is of type "string" with the value "Array".
I want $first to be a string. In the case of Joe Schmoe, it should be
the string "Joe".
How? I've tried everything I can think of....
--
Kindest regards,
Erik J. Barzeski
99 little bugs in the code, 99 bugs in the code,
fix one bug, compile it again...
101 little bugs in the code....
************************************************
Email: erik@barzeski.com
Web: http://www.barzeski.com/
http://www.soundsetcentral.com/
http://www.applescriptcentral.com/
AIM: iacas ICQ: 8186546
************************************************