Re: [PHP] Count the Number of Elements Using Explode

2008-11-01 Thread Lars Torben Wilson
2008/10/31 Stut [EMAIL PROTECTED]: On 31 Oct 2008, at 17:32, Maciek Sokolewicz wrote: Kyle Terry wrote: -- Forwarded message -- From: Kyle Terry [EMAIL PROTECTED] Date: Fri, Oct 31, 2008 at 9:31 AM Subject: Re: [PHP] Count the Number of Elements Using Explode To: Alice Wei

[PHP] Count the Number of Elements Using Explode

2008-10-31 Thread Alice Wei
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

Fwd: [PHP] Count the Number of Elements Using Explode

2008-10-31 Thread Kyle Terry
-- Forwarded message -- From: Kyle Terry [EMAIL PROTECTED] Date: Fri, Oct 31, 2008 at 9:31 AM Subject: Re: [PHP] Count the Number of Elements Using Explode To: Alice Wei [EMAIL PROTECTED] I would use http://us2.php.net/manual/en/function.array-count-values.php On Fri, Oct 31

Re: [PHP] Count the Number of Elements Using Explode

2008-10-31 Thread Daniel Brown
On Fri, Oct 31, 2008 at 11:29 AM, Alice Wei [EMAIL PROTECTED] wrote: 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

Re: [PHP] Count the Number of Elements Using Explode

2008-10-31 Thread Diogo Neves
Hi Alice, U can simple do: $nr = ( strlen( $message ) / 2 ) + 1 ); $nr = count( explode( '|', $message ); On Fri, Oct 31, 2008 at 4:32 PM, Daniel Brown [EMAIL PROTECTED] wrote: On Fri, Oct 31, 2008 at 11:29 AM, Alice Wei [EMAIL PROTECTED] wrote: Hi, I have a code snippet here as

RE: [PHP] Count the Number of Elements Using Explode

2008-10-31 Thread Alice Wei
, 31 Oct 2008 17:00:44 + From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] CC: [EMAIL PROTECTED]; php-general@lists.php.net Subject: Re: [PHP] Count the Number of Elements Using Explode Hi Alice, U can simple do: $nr = ( strlen( $message ) / 2 ) + 1 ); $nr = count( explode( '|', $message

Re: [PHP] Count the Number of Elements Using Explode

2008-10-31 Thread Matthew Powell
Diogo Neves wrote: Hi Alice, U can simple do: $nr = ( strlen( $message ) / 2 ) + 1 ); $nr = count( explode( '|', $message ); Or... $num = (substr_count($message, |) + 1); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: Fwd: [PHP] Count the Number of Elements Using Explode

2008-10-31 Thread Maciek Sokolewicz
Kyle Terry wrote: -- Forwarded message -- From: Kyle Terry [EMAIL PROTECTED] Date: Fri, Oct 31, 2008 at 9:31 AM Subject: Re: [PHP] Count the Number of Elements Using Explode To: Alice Wei [EMAIL PROTECTED] I would use http://us2.php.net/manual/en/function.array-count-values.php

Re: [PHP] Count the Number of Elements Using Explode

2008-10-31 Thread Stut
On 31 Oct 2008, at 17:32, Maciek Sokolewicz wrote: Kyle Terry wrote: -- Forwarded message -- From: Kyle Terry [EMAIL PROTECTED] Date: Fri, Oct 31, 2008 at 9:31 AM Subject: Re: [PHP] Count the Number of Elements Using Explode To: Alice Wei [EMAIL PROTECTED] I would use http://us2