d_barszczak Posted June 5, 2008 Share Posted June 5, 2008 Hi All. I need to convert a variable : myVar = "Test". Into an array : myArray[0] = T, myArray[1] = e, myArray[2] = s. and so on. Does anyone have any ideas? Quote Link to comment Share on other sites More sharing options...
kbh43dz_u Posted June 5, 2008 Share Posted June 5, 2008 simply use echo $myVar[0]; you can access every letter from a string like an array. edit: if you still need it in an array: for ($i = 0; $i < strlen($myVar); $i++){ $array[] = $myVar[$i]; } or for ($i = 0; $i < strlen($myVar); $i++){ $array[] = substr ($myVar, $i, 1); } Quote Link to comment Share on other sites More sharing options...
haku Posted June 5, 2008 Share Posted June 5, 2008 myvar = myvar.split("") Quote Link to comment Share on other sites More sharing options...
d_barszczak Posted June 5, 2008 Author Share Posted June 5, 2008 Thanks!! I thnk the first reply is a php script not a JavaScript The second reply got it though, thanks again!!! Quote Link to comment Share on other sites More sharing options...
kbh43dz_u Posted June 5, 2008 Share Posted June 5, 2008 sorry, i missed that it's about Javascript 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.