I got this IF - FOREACH - THING here (I know that's a bit stupidly done ... adding "," to $num and removing it ...
My excuse is, that Im just a poor student with goal to someday become good at this kind of stuff and currently I don't care if there's something done stupidly ... cause if I ever try to fix that, it will not work):
if (isset($_GET["num"])) { foreach ($_GET["num"] as $arvo) $num = $num . $arvo . ",";
$numchk[] = $num;}
$numchktostring = $numchk[0];
$num2 = explode(",", $numchktostring);
$validchk = count($num2);
Now, it somewhy gives me output like this (By var_dumping $num2):
array(7) { [0]=> string
(1) "1" [1]=> string
(1) "2" [2]=> string
(1) "3" [3]=> string
(1) "4" [4]=> string
(1) "5" [5]=> string
(1) "6" [6]=> string
(1) "7" }
As you can see, every single key is a string.
My guestion is plain simple; how to make those strings int?
I have this example-snippet here, but how do I use it to array? (loop preferred):
$str = "10";
$num = (int)$str;
-- EDIT --This seems to turn the variables to int, but it loses the avlue given to them before:
$i = 0;
$a = 0;
While ($i < 7) {
$num2[$a] = (int)$num2[$a];
$i++;
$a++;
}
var_dump($num2) outputs now:
array(7) { [0]=> int
(1) [1]=> int
(2) [2]=> int
(3) [3]=> int
(4) [4]=> int
(5) [5]=> int
(6) [6]=> int
(7) }