Re: string to array

From: Date: Fri, 08 Nov 2002 13:36:39 +0000
Subject: Re: string to array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-123372@lists.php.net to get a copy of this message
String IS an array. Basically, you could do this: $str = 'The Dummy String'; for($i=0; $i<strlen($str); $i++) { echo $str[$i] . ':'; } and you sould get the output: T:h:e: :D:u:m:m:y: :S:t:r:i:n:g: As of actually converting it you could do that very loop and have an: $atr_arr[] = $str[$i] in it, or, even more elegantly by using split() function or "...chunk.." something function(), don't remember right now. -- Maxim Maletsky maxim@php.net Marek Kilimajer <kilimajer@webglobe.sk> wrote... : > Hi all, > > has anyone an elegant (and faster) way of converting 'string' to > array('s','t','r','i','n','g'), > other then > for($i=0; $i<strlen($string); $i++) $array[$i]=$string[$i]; > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#123372) next »