[thelist] preg_split in PHP
alpha at student.uci.agh.edu.pl
alpha at student.uci.agh.edu.pl
Mon Jan 14 19:54:43 CST 2002
On Mon, Jan 14, 2002 at 08:33:35PM -0500, noah wrote:
> string is just a number (e.g., 2457) and I want to split it into individual
> digits.
> $acts = preg_split('//', '2457');
Why do you use split for such task? String is an array, so you can
easily access each digit by its index in the string:
$a='2457';
echo $a[0]; # gives 2
echo $a[2]; # gives 5
Hope that helps...
Adam
--
_.|._ |_ _. | Adam Byrtek, alpha at irc.pl
(_|||_)| |(_| | gg 1802819
|
More information about the thelist
mailing list