Dale_G Posted May 8, 2008 Share Posted May 8, 2008 Hey everyone. Say I have a string, which...could be any combination of letters and numbers. For example. $string = 'fhkhj4h21j'; How can I put ALL of the characters into an array and access them by $string[0], $string[1], $string[2], and so on and so on... Basically...exploding the string by..nothing! Regardless of string content (numbers and letters), all individual characters will be put into an array. How can that be done? Quote Link to comment https://forums.phpfreaks.com/topic/104780-solved-explode-a-string-bynothing-essentially-seperate-all-chars-into-an-array/ Share on other sites More sharing options...
trq Posted May 8, 2008 Share Posted May 8, 2008 <?php $string = 'fhkhj4h21j'; echo $string[2]; ?> Works already! Quote Link to comment https://forums.phpfreaks.com/topic/104780-solved-explode-a-string-bynothing-essentially-seperate-all-chars-into-an-array/#findComment-536371 Share on other sites More sharing options...
Dale_G Posted May 8, 2008 Author Share Posted May 8, 2008 Hah, wow. Well, thanks. XD Quote Link to comment https://forums.phpfreaks.com/topic/104780-solved-explode-a-string-bynothing-essentially-seperate-all-chars-into-an-array/#findComment-536373 Share on other sites More sharing options...
ToonMariner Posted May 8, 2008 Share Posted May 8, 2008 you can actually reference your string as an array in exactly the way you show. $string{2} has been used but I believe in php6 you will only be able to use $string[2] notation. so get the size of the 'array' just use strlen(); Quote Link to comment https://forums.phpfreaks.com/topic/104780-solved-explode-a-string-bynothing-essentially-seperate-all-chars-into-an-array/#findComment-536376 Share on other sites More sharing options...
Dale_G Posted May 8, 2008 Author Share Posted May 8, 2008 Oh, thanks for that extra info. Quote Link to comment https://forums.phpfreaks.com/topic/104780-solved-explode-a-string-bynothing-essentially-seperate-all-chars-into-an-array/#findComment-536383 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.