RE: [PHP] string length?
| From: | Maxim Maletsky | Date: | Wed, 31 Jan 2001 11:32:43 +0000 |
| Subject: | RE: [PHP] string length? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-37456@lists.php.net to get a copy of this message | ||
I would do :
$num = substr_count($numbers, ';'); +/- whatever the difference it could
make
Cheers,
Maxim Maletsky
-----Original Message-----
From: Joe Stump [mailto:jstump@zebulon.miester.org]
Sent: Wednesday, January 31, 2001 12:29 PM
To: Jon Jacob
Cc: php-general@lists.php.net
Subject: Re: [PHP] string length?
if you just want to know how many numbers are in it you can do this:
$num_of_numbers = sizeof(explode(';',$string));
--Joe
On Tue, Jan 30, 2001 at 04:46:50PM -0800, Jon Jacob wrote:
> Kevin Connolly wrote:
> >
> > Hi,
> > I am quite new to PHP scripts and I have run into a little problem with
my string!
> > I have a string called $numbers which is 5;6;12;21;36;42 (for example,
it can be any 6 numbers between 1 and 42).
> > Is there an easy way that I can find out how many numbers there are in
the string without the five semi-colons??
> > I was playing around with count_chars but had no success!
> > then i tried converting it to an array and counting the number of
elements in the array but unfortunatley it put the whole string in as the
first element of the array and returned a size of 1!
> > I would appreciate any help you can give me,
> > Cheers,
> > Kevin.
>
> Use split.
>
> (@ArrayName) = split (":", $numbers);
> $ElementsNum = count(@ArrayName);
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
--
----------------------------------------------------------------------------
---
Joe Stump, PHP Hacker, joestump98@yahoo.com
-o)
http://www.miester.org http://www.care2.com
/\\
"It's not enough to succeed. Everyone else must fail" -- Larry Ellison
_\_V
----------------------------------------------------------------------------
---
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net