Re: string length?

From: Date: Wed, 31 Jan 2001 01:21:53 +0000
Subject: Re: string length?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-37365@lists.php.net to get a copy of this message
Hi Kevin, First thought that comes to mind is explode() so something like : <?php $string = '5;6;12;21;36;42'; $count = count(explode(';',$string)); ?> I assume that would work. That explodes it into an array then counts it, check out : http://www.php.net/manual/en/function.explode.php It's a really fun function to play with. Regards, Philip Olson http://www.cornado.com/ On Tue, 30 Jan 2001, 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. > >

« previous php.general (#37365) next »