There are arrays:

$array_8 $array_9 

Their number and numbers may be different. The numbers are stored in a separate $ arr_id array.

Example $ arr_id:

 Array ( [0] => 8 [1] => 9 ) 

Tell me, please, is it possible to somehow sort through these arrays without manually specifying the number?

Something like that:

 <?php foreach ($arr_id as $id) { ?> <?php foreach ($array_"тут номер $id" as $value) { ?> 

    2 answers 2

    @ Ipatiev, as always, speaks the truth. But if there is no possibility to correct the data, you can do this:

     foreach ($arr_id as $id) { foreach (${'array_' . $id} as $value) { 

    More details here , in the Complex (curly) syntax section .

    Or so:

     foreach ($arr_id as $id) { $arr_name = 'array_' . $id; foreach ($$arr_name as $value) { 

    Read more about variables .

    • one
      with $$ will be clearer , IMHO - teran 1:08 pm
    • This is the third option, he added. - u_mulder 1:09 pm
    • one
      you still have complicated syntax with the figures, not $$ - teran pm
    • Well, it's just a nightmare) - u_mulder 1:14 pm

    There are arrays:

    They should not be.

    Must be a single array whose elements are the specified arrays

     Array ( [8] => [/* массив $array_8 */], [9] => [/* массив $array_9 */], ) 

    and this array is already recruited using the usual foreach ()

    • one
      maybe a person already has for example a set of php files, in each of which a certain $array_X . So it should not, but perhaps this is the basic data. - teran