另一个foreach里面的foreach循环

I have courses and schools array. I want to use schools array inside of courses array:

<? foreach ($courses as $course) {
    <div class="cat_row">
        <?= $course['location'] ?>
    </div>
<? } ?>

When I use

<? foreach($schools as $coordinate){
    echo $coordinate->latitude;
} ?>

inside of the first foreach it shows in every block all coordinates, like:

|first|second|third|
|1 2 3|1 2 3 |1 2 3|

How can I make as:

|first|second|third|
|1    |2     |3    |

? Can anyone help me with it?

You should use just one foreach if number of items in both arrays are equal

<? foreach ($courses as $key=>$course) {
<div class="cat_row">
    <?= $course['location'] ?>
    <?= $schools[$key]->latitude ?>
</div>
<? } ?>