如何为数组中的每个数组编写代码

I am new to this so please do not judge.

  1. I have transformed a .csv file into an array([0]=>array([0]=>string(), [1]=>string())[1]=>array([0]=>string(), [1]=>string()) etc. So I can access it numerically i.e. $the_big_array[1][1]

  2. Now I want the program to write a couple of lines of code for each array within an array.

  3. Basically what I am doing is creating a table like this that will be encoded in json.

    $request['AddPrice'][0][variable1] = $the_big_array[1][2] $request['AddPrice'][0][variable2] = $the_big_array[1][3]

and I want different values loaded for and from each line of .csv file/$the_big_array

$request['AddPrice'][1][variable1] = $the_big_array[1][2]
$request['AddPrice'][1][variable2] = $the_big_array[1][3]

I am stuck at foreach function as I cannot grasp how to make it execute certain action for each array within an array.

You have to use a foreach loop for every array dimension. If You have 2 dimensions, like in $the_big_array[1][1], go through the first dimension with your first loop. Inside this loop, do another foreach to go through your second dimension.

so I have fixed this problem. Perhaps the question was not clear enough.

What I did was to create arrays with maximum occupancy for each of my rooms and add nested foreachloop for each occupancy, so it has to repeat until maximum occupancy is reached and only then it can iterate to the next key in the first foreachloop.