Re: Character Array

From: Date: Thu, 11 Jul 2002 11:50:59 +0000
Subject: Re: Character Array
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-107101@lists.php.net to get a copy of this message
> >Is there an easy way to get an array of characters from a string? > $str = 'string'; > $chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY); > print_r($chars); A string is already an array of chars : $toto="test"; echo $toto[0]; // prints t echo $toto[1]; // prints e echo $toto[2]; // prints s echo $toto[3]; // prints t

« previous php.general (#107101) next »