Forum Moderators: coopster

Message Too Old, No Replies

Split a number with PHP

         

leeparts

2:09 pm on Mar 14, 2008 (gmt 0)

10+ Year Member



Hi All,
This may be very easy or not possible, but I am trying to use php to take a number and split it up.

Example - 1234567

Split it up to:
1
2
3
4
5
6
7

Can anyone help?

coopster

2:31 pm on Mar 14, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



$n = 1234567; 
$n = str_split [php.net]($n);

PHP silently converts the number to a string before it splits it.

leeparts

2:57 pm on Mar 14, 2008 (gmt 0)

10+ Year Member



Thank you, that does the trick!