Working with an array

Greetings to all who came.

Hunting to create an array with numbers like (2,3,5,7,11,13…); I can create an array, but I need an array with a large number of values; the question is how to write it so that it is as short as possible?

The array will be replenished, then by iteration, try to divide a certain variable by each value from the array. Actually, in my last topic there was such a construction:

while ($d001=mysql_fetch_assoc($q001)){extract($d001);if($i001<1){$x001=$n001/$d001['id'];$t001=$x001-$d001['id'];if($t001>=0){$re001=$n001%$d001['id'];if($re001==0){$i001=$i001+1;};};};}

Search on factors from the table. So I want to know, is it possible to do a search on a pre-made array?


Answer 1, authority 100%

If I understand correctly, you want a loop that iterates over the elements of an array.
It’s either

$arr = array(,,,,,,);
for($i=0;$i<count($arr);$i++){
 //$arr[$i] -   
}

Or if the keys are arbitrary

foreach($arr as $arr_key=>$arr_value){
 //$arr_value -   
 //$arr_key -    
 //$arr[$arr_key] -   
}

Answer 2

Judging by the values, we need prime numbers. Then the sieve of Erastothenes is true. If you just want to create a big array, use manuals