Думаю верно вас понял
<?php
/**
* Created by PhpStorm.
* User: alex
* Date: 08.05.16
* Time: 17:57
*/
$resurses = array("0" => array(
"id" => "7", "input_ingridient" => "Железная руда", "input_value" => "2000",
"output_ingridient" => "Сталь", "output_value" => "1600"),
"1" => array(
"id" => "5", "input_ingridient" => "Древесина", "input_value" => "1000", "output_ingridient" => "Бревно",
"output_value" => "600"));
$recipes = array(
"0" => array(
"id" => "4", "title_recipe" => "Первый рецепт", "1_title_ingridient" => "Сталь",
"1_value_ingridient" => "200", "2_title_ingridient" => "Название 2", "2_value_ingridient" => "2",
"3_title_ingridient" => "Название 3",
"3_value_ingridient" => "3", "4_title_ingridient" => "Название 4", "4_value_ingridient" => "4",
"5_title_ingridient" => "Название 5",
"5_value_ingridient" => "5", "6_title_ingridient" => "Название 6", "6_value_ingridient" => "6",
"7_title_ingridient" => "Название 7",
"7_value_ingridient" => "7", "8_title_ingridient" => "Название 8", "8_value_ingridient" => "8",
"9_title_ingridient" => "Название 9",
"9_value_ingridient" => "9", "10_title_ingridient" => "Название 10", "10_value_ingridient" => "10"),
"1" => array(
"id" => "2", "title_recipe" => "Второй рецепт", "1_title_ingridient" => "Название 11",
"1_value_ingridient" => "234234", "2_title_ingridient" => "Название 12", "2_value_ingridient" => "234234",
"3_title_ingridient" => "Название 13", "3_value_ingridient" => "434", "4_title_ingridient" => "Название 14",
"4_value_ingridient" => "43443", "5_title_ingridient" => "Название 15", "5_value_ingridient" => "100",
"6_title_ingridient" => "Название 6", "6_value_ingridient" => "23423", "7_title_ingridient" => "Название 7",
"7_value_ingridient" => "234234", "8_title_ingridient" => "Название 8", "8_value_ingridient" => "234324",
"9_title_ingridient" => "Название 9", "9_value_ingridient" => "43", "10_title_ingridient" => "Название 10",
"10_value_ingridient" => "4"));
function resurses($resurses, $recipes)
{
foreach ($resurses as $key => $resurse) {
foreach ($recipes as $recipe) {
$qty = count($recipe);
foreach ($recipe as $key_item => $item) {
$qty--;
if ($resurse['output_ingridient'] == $recipe[$qty . '_title_ingridient']) {
$resurses[$key]['input_value'] = $recipe[$qty . '_value_ingridient'] * $resurse['input_value'];
for ($i = 1; $i <= 10; $i++) {
$resurses[$key][$i . '_title_ingridient'] = $recipe[$i . '_title_ingridient'];
$resurses[$key][$i . '_value_ingridient'] = $recipe[$i . '_value_ingridient'];
}
}
}
}
}
return $resurses;
}
$resurses = resurses($resurses, $recipes);
foreach ($resurses as $a) {
$qty_res = (count($a) - 6) / 2;
echo ' <div class="panel panel-default custom-panel">
<div class="panel-heading">Title recipe</div>
<div class="panel-body">
<ul class="list-group res">
<li class="list-group-item">' . $a['input_ingridient'] . ' <span class="badge">' . $a['input_value'] . '</span></li>';
for ($i = 1; $i <= $qty_res; $i++) {
echo '<li class="list-group-item custom-list-group-item">' . $a[$i . '_title_ingridient'] .
' <span class="badge custom-badge">' . $a[$i . '_value_ingridient'] . '</span></li>';
}
echo ' </ul>
</div>
<div class="panel-footer">Показано количество ингридиентов на одно изготовление.</div>
</div>';
}