By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,746 Members | 1,735 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,746 IT Pros & Developers. It's quick & easy.

Weird array

P: n/a
I'm executing these commands:

$text="example text";
$parts=explode(" ", $text);
$result=$parts[0];

$result becomes a weird array.

echo "$result" prints 'example',

but if I use function count_chars($result) i got error message, that $result
is an array not a string.

Please tell me how to make my $result be a string

Thanks

Domin
domin(at)zyx.pl
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hello Dominik,

Dominik B. wrote:
I'm executing these commands:

$text="example text";
$parts=explode(" ", $text);
$result=$parts[0];

$result becomes a weird array.

echo "$result" prints 'example',

but if I use function count_chars($result) i got error message, that
$result is an array not a string.

Please tell me how to make my $result be a string


There's nothing wrong with the code you posted,
I tried it on my machine.

What may be causing some confusion is count_chars().
Please realize that this function is _not_ for getting
the string length. Instead it by default returns an array
of all possible characters and the number of times they occur
in the string.

If you want a function that simply returns the string length,
then strlen() is what you're looking for.

Best regards,

Eric
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.