rhyspaterson Posted May 28, 2007 Share Posted May 28, 2007 Hey guys, Just been thinking. I have been looking at PHP explode lately, and it struck me, how do you explode a number such as: 000000001000000000100000000001000 So that each number is in it's own array? I have no idea.. any suggestions? Cheers, /Rhys Quote Link to comment https://forums.phpfreaks.com/topic/53264-solved-php-explode/ Share on other sites More sharing options...
AndyB Posted May 28, 2007 Share Posted May 28, 2007 Strings are arrays ... <?php $num = "000000001000000000100000000001000"; // number as a string echo $num{4}; // note the curly braces Quote Link to comment https://forums.phpfreaks.com/topic/53264-solved-php-explode/#findComment-263186 Share on other sites More sharing options...
Vinze Posted May 28, 2007 Share Posted May 28, 2007 I know you should be able to do this in a better way, but I think this would work: $string = '000000001000000000100000000001000'; $length = strlen($string); $array = array(); for($i = 0; $i < $length; $i++) { $array[] = substr($string, $i, 1); } Quote Link to comment https://forums.phpfreaks.com/topic/53264-solved-php-explode/#findComment-263187 Share on other sites More sharing options...
rhyspaterson Posted May 28, 2007 Author Share Posted May 28, 2007 Well. You learn something new every day. Thanks for your replies. I must look like an idiot, haha. Quote Link to comment https://forums.phpfreaks.com/topic/53264-solved-php-explode/#findComment-263188 Share on other sites More sharing options...
Vinze Posted May 28, 2007 Share Posted May 28, 2007 Well. You learn something new every day. Thanks for your replies. I must look like an idiot, haha. You're not an idiot if you learn something new Quote Link to comment https://forums.phpfreaks.com/topic/53264-solved-php-explode/#findComment-263190 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.