RE: [PHP] newbie: string to char array

From: Date: Wed, 10 Nov 2004 12:21:26 +0000
Subject: RE: [PHP] newbie: string to char array
Groups: php.general 
Request: Send a blank email to php-general+get-201658@lists.php.net to get a copy of this message
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm > -----Original Message----- > From: Horst Jäger [mailto:h.jaeger@medienkonzepte.de] > Sent: 10 November 2004 09:51 > > I wonder if it is possible to convert a given string into an > array of chars > without using a separator. > > That is, is there a function > > mySplit > > with > > mySplit('example') == array('e', 'x', 'a', > 'm', 'p' 'l' 'e') ? Do you absolutely need it as an array? If indexing by character would suffice, just use PHP's {} syntax: $s = 'example'; echo $s{0}; // e echo $s{1}; // x // etc. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: m.ford@leedsmet.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#201658) next »