There is a MySQL query:

$q = $db->query("SELECT `uvk_id` FROM `users` ORDER BY `uid` ASC LIMIT 900"); while($d = $db->assoc($q)) { $vk_id_list[] = $d['uvk_id']; } 

$vk_id_list is an array that contains 900 values ​​with VK id.

I need to create 3 arrays in which there will be 300 values , for example:

$array1 will contain from 0 to 300 values ​​from the general $vk_id_list

$array2 will contain from 300 to 600 values ​​from the total $vk_id_list

$array3 will contain from 600 to 900 values ​​from the total $vk_id_list

Do not tell me how to implement?

  • @ReinRaus ♦, took an array_slice. Turn your comment in response. - ModaL

1 answer 1

http://php.net/manual/ru/function.array-slice.php
Or so:

 $name= "array1"; $counter=0; $q = $db->query("SELECT `uvk_id` FROM `users` ORDER BY `uid` ASC LIMIT 900"); while($d = $db->assoc($q)) { $$name[] = $d['uvk_id']; $counter++; if ($counter%300==0) { $name= preg_replace("/\\d/", "", $name).($counter\300 +1 ); }; } 
  • Thank you very much! - ModaL