C
C
chilloutbboyz2020-09-01 20:58:55
PHP
chilloutbboyz, 2020-09-01 20:58:55

How to work with multidimensional arrays?

Hello again, again I'm with a child's problem and would be very grateful if you would try to explain how it works.

$garages = [
    1 => ['id' => 1, 'name' => 'Гараж на улице 1', 'size' => 1],
    7 => ['id' => 7, 'name' => 'Подземная парковка', 'size' => 100],
    23 => ['id' => 23, 'name' => 'У домика в деревне', 'size' => 2],
];

// машины
$cars = [
    ['name' => 'Белый Ford', 'garageId' => 7],
    ['name' => 'Черный Уаз', 'garageId' => 1],
    ['name' => 'Синий Таз',  'garageId' => 7],
];

Each car has the id of the garage in which this car is located

Print a separate line for each car, like this: Car "CAR NAME" is in "GARAGE NAME"
I understand that the problems are childish, but I would be grateful for an explanation of the solution to this problem.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
DevMan, 2020-09-01
@chilloutbboyz

foreach($cars as $car) {
  echo "Машина \"{$car['name']}\" стоит в \"{$garages[$car['garageId']]['name']}\"", PHP_EOL;
}

D
Dmitry Kinash, 2015-07-30
@rossoxa

The query throws an error for the variable name &True . Matches the keyword True . What a stupid name? Name essentially - &Modifier . If the value of the parameter is always true, then why is the parameter even there? Compare with the keyword or remove the comparison altogether - if the Modifier attribute from the Modifiers directory, to which the Nomenclature reference refers to with its attribute (well, you wrapped up with the architecture, you can still make it much easier), is boolean, then it is enough in the WHERE section . Example: Select * from Catalog.Nomenclature Where not Deletion Mark .

T
thepry, 2015-07-30
@thepry

Make a request to TC

ВЫБРАТЬ
бла-бла-бла
ИЗ
Справочник.Номенклатура.Модификаторы

And the nomenclature itself will be available in the "Link" field.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question