I am trying to reate an array that contains all the odd numbers between 1
to 20,000
. I Use the var_dump()
at the end to display the array values without using loops.
For some reason it won't work out.
here's my code so far:
$array_variable = array();
for($i=1; $i<=20000; $i++){
if($i%2 == 1){ // if the remainder after division `$i` by 2 is one{
print_r($array_variable[$i]); // if odd, echo it out and then echo newline for better readability;
}
}
var_dump($array_variable);