Re: [PHP] Splitting 12345 - 1,2,3,4,5
Michael Mao wrote: Thanks John. Found what I'm looking for: Function str_split() to make it php4 compatible you can use this function: |?php if (!function_exists('str_split')) { function str_split ($str, $size = 1) { $arr = array(); for ($i = 0 ; $i strlen($str) ; $i += $size) { $arr[] = substr($str,$i,$size); } return $arr; } } ? works in about the same way as the function in php5. | -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Splitting 12345 - 1,2,3,4,5
Martin Holm wrote: Michael Mao wrote: Thanks John. Found what I'm looking for: Function str_split() to make it php4 compatible you can use this function: |?php if (!function_exists('str_split')) { function str_split ($str, $size = 1) { $arr = array(); for ($i = 0 ; $i strlen($str) ; $i += $size) { $arr[] = substr($str,$i,$size); here, you can also use: $arr[] = $str{$i}; and use $i++ instead of $i += $size if you don't need strings larger than 1 character. } return $arr; } } ? works in about the same way as the function in php5. | -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Splitting 12345 - 1,2,3,4,5
Anyone know how I can split a number into individual digits? Thanks, Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Splitting 12345 - 1,2,3,4,5
Michael Mao wrote: Anyone know how I can split a number into individual digits? http://us2.php.net/manual/en/function.preg-split.php -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Splitting 12345 - 1,2,3,4,5
Thanks John. Found what I'm looking for: Function str_split() On Wed, 15 Sep 2004 23:48:33 -0400, John Holmes [EMAIL PROTECTED] wrote: Michael Mao wrote: Anyone know how I can split a number into individual digits? http://us2.php.net/manual/en/function.preg-split.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php