Count the Number of Elements Using Explode
| From: | Alice Wei | Date: | Fri, 31 Oct 2008 16:29:48 +0000 |
| Subject: | Count the Number of Elements Using Explode | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-282710@lists.php.net to get a copy of this message | ||
Hi,
I have a code snippet here as follows:
$message="1|2|3|4|5";
$stringChunks = explode("|", $message);
Is it possible to find out the number of elements in this string? It seems that I could do things
like print_r and find out what is the last element of $stringChunks is, but is there a way where I
can use code from the two lines and have it print out 5 as the number of elements that contains
after the splitting?
Or, am I on the wrong direction here?
Thanks in advance.
Alice
_________________________________________________________________
Check the weather nationwide with MSN Search: Try it now!
http://search.msn.com/results.aspx?q=weather&FORM=WLMTAG