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? Link to comment https://forums.phpfreaks.com/topic/108822-solved-help-with-variables/ 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); } Link to comment https://forums.phpfreaks.com/topic/108822-solved-help-with-variables/#findComment-558194 Share on other sites More sharing options...
haku Posted June 5, 2008 Share Posted June 5, 2008 myvar = myvar.split("") Link to comment https://forums.phpfreaks.com/topic/108822-solved-help-with-variables/#findComment-558200 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!!! Link to comment https://forums.phpfreaks.com/topic/108822-solved-help-with-variables/#findComment-558202 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 Link to comment https://forums.phpfreaks.com/topic/108822-solved-help-with-variables/#findComment-558264 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.