Re: Convert a string to an array w/o spliting or exploding

From: Date: Wed, 13 Feb 2002 17:06:22 +0000
Subject: Re: Convert a string to an array w/o spliting or exploding
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-84603@lists.php.net to get a copy of this message
On Wednesday, February 13, 2002, at 10:19 AM, brendan conroy wrote:
Hi, thanks for reading this novice question, I'd be grateful if someone could email me and tell me if its possible to convert a string to an array whithout using the split[] or explode[] function, as these aren't appropriate for the task. I cant find any ino on php.net,
Technically, a string is an array. Use braces rather than brackets when doing this: $string = "erikprice"; print $string{0}; // prints "e" print $string{1}; // prints "r" print $string{2}; // prints "i" print $string{3}; // prints "k" print $string{4}; // prints "p" print $string{5}; // prints "r" print $string{6}; // prints "i" I hope you get the picture. NB I haven't tested this code, but the theory is right. Check the online documentation, I think under variables -- this is kind of hidden. If you don't mean a character-based array, you'll have to be more specific about what you're asking -- provide an example. Also, are you sure you mean to use brackets when you say 'split[]' and 'explode[]' ? It's supposed to be parentheses. 'split()', 'explode()'. Erik ---- Erik Price Web Developer Temp Media Lab, H.H. Brown pricee@hhbrown.com

« previous php.general (#84603) next »