Re: String to an Array

From: Date: Sun, 08 Dec 2002 00:15:49 +0000
Subject: Re: String to an Array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-127405@lists.php.net to get a copy of this message
I *think* either: <? $str = "im the one trying to do this"; echo $str[0]; ?> OR <? $str = "im the one trying to do this"; echo $str{0}; ?> Works -- you'll have to experiment, but I believe the second way is correct, and will echo the first (0th) character in the string. If you want to get more than 1 character from a string (example, characters 2-5), then use substr() -- check out the manual. So far, I don't think you've shown a need for the string to be converted to to an array... Justin on 06/12/02 5:50 AM, Rodrigo de Oliveira Costa (thenewsource@ieg.com.br) wrote: > Hi guys, I got a string that I need to be transformed into na array of > characters, something like: > > > $str ="im the one trying to do this"; > > //this is the string > > I'd like to get an array that I can access something like $array[0] and > get the value " i ". And this foward. Anyone have any clues on this? > > Thanks, > Rodrigo > > Justin French -------------------- http://Indent.com.au Web Development & Graphic Design --------------------

« previous php.general (#127405) next »