newbtophp Posted September 7, 2010 Share Posted September 7, 2010 $array = array(); for ($i = 97; $i < 123; $i++) { $array[] = chr($i); } for ($i = 65; $i < 91; $i++) { $array[] = chr($i); } Its quite time consuming looping, perhaps combine in 1 or? Quote Link to comment Share on other sites More sharing options...
Psycho Posted September 7, 2010 Share Posted September 7, 2010 Well, you can reference characters in a string the same way you reference elements in an array. So the simplest solution would be to simply define a string with all the characters $array = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; However, if you need to keep it as an array construct and/or need it to be done programatically, then this might be more efficient $array = array_merge(range(97, 122), range(65, 90)); $array = array_map("chr", $array); However, there are many different possible solutions and I can't say which would be more efficient without testing. Quote Link to comment Share on other sites More sharing options...
newbtophp Posted September 7, 2010 Author Share Posted September 7, 2010 Thanks mjdamato I used your first example Quote Link to comment 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.