A
A
arsenaljek2020-04-24 09:09:43
PHP
arsenaljek, 2020-04-24 09:09:43

How to iterate over 2 arrays?

There are 2 arrays The first with cities

Array
(
    [0] => Array
        (
            [count] => 1
            [name_city] => Абакан
            [id_city] => 46
        )

    [1] => Array
        (
            [count] => 1
            [name_city] => Ачинск
            [id_city] => 1
        )

)

Second with dealers
Array
(
    [0] => Array
        (
            [dealer_city_id] => 46
            [dealer_name] => дилер 1
            [dealer_phone] => телефон
            [dealer_email] => емейл
            [dealer_site] => сайт
        )

    [1] => Array
        (
            [dealer_city_id] => 1
            [dealer_name] => дилер 1
            [dealer_phone] => телефон
            [dealer_email] => емейл
            [dealer_site] => сайт
        )

)

I need to bring this case to the accordion
<div class="accordion" id="rusdealer">
                        <div class="card">
                            <div class="card-header pt-0 pb-0" id="headingOne">
                                <div class="pt-1 float-right">
                                    <span class="badge badge-primary"> <?=$row['count']?></span>
                                </div>
                                <h5 class="card-title my-2">
                                    <a href="#" data-toggle="collapse" data-target="#collapse-<?=$row['id_city']?>" aria-expanded="true" aria-controls="collapseO-<?=$row['id_city']?>"><?=$row['name_city']?>
                                    </a>
                                </h5>
                            </div>
                            <div id="collapse-<?=$row['id_city']?>" class="collapse" aria-labelledby="headingOne" data-parent="#rusdealer">
                                <div class="card-body">
                                    <div class="row">
                                        <div class="col-12 col-lg-6">
                                            <div class="card mb-3 border">
                                                <div class="card-header">
                                                    <h5 class="card-title mb-0"><?=$row2['name_dil']?></h5>
                                                </div>
                                                <div class="card-body pt-0">
                                                    <ul class="list-unstyled mb-0">
                                                        <li class="mb-1"><i class="fas fa-phone"></i> <?=$phone?>
                                                        <li class="mb-1"><i class="fas fa-envelope"></i> <a href="mailto:<?=$row2['email_dil']?>"><?=$row2['email_dil']?></a></li>
                                                        <li class="mb-1"><i class="fas fa-globe"></i> <a href="https://<?=$row2['site_dil']?>" target="_blank"><?=$row2['site_dil']?></a></li>
                                                    </ul>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

Help with foreach. I don't understand how to get it out

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanatPHP, 2020-04-24
@arsenaljek

Haven't mastered your accordion yet?
Well, I chewed
everything for you Array one , two foreach-and
there cases for 15 minutes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question