If $string is a string, like :
$string = '312';
Then one can do :
$string[0]; // 3
$string[1]; // 1
$string[2]; // 2
Note, '312' is a string and will work using above but if we define 312 as
an integer like :
$string = 312;
Then $string[0] will not "work" and it'll need to
> I have a string of 1034 and I want to have an array that has each number in
> an element.(ex: num[0] = 1, num[1] = 0, num[2] = 3 num[3] = 4) Is there a
> way to explode a string by each character?
Just convert it to a string: ie. $foo = (string)$num; echo $foo[1];
-Rasmus
--
PHP General M
Hello,
I have a string of 1034 and I want to have an array that has each number in
an element.(ex: num[0] = 1, num[1] = 0, num[2] = 3 num[3] = 4) Is there a
way to explode a string by each character?
Thank you,
Brandon Orther
WebIntellects Design/Dev
3 matches
Mail list logo