On Wed, 2002-02-13 at 09:06, Erik Price wrote: > > 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:
No, a string in PHP is one of the scalar types; array is complex. In C a string is an array, though. ;) For historical reasons it is still possible to use brackets to access string offsets, but this is deprecated: http://www.php.net/manual/en/language.types.string.php#language.types.string.substr For instance, try using a string in one of the array functions, or vice versa. A bit more about the difference is presented in 'Type Casting': http://www.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting Torben > $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 -- Torben Wilson <[EMAIL PROTECTED]> http://www.thebuttlesschaps.com http://www.hybrid17.com http://www.inflatableeye.com +1.604.709.0506 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php