'; array_push($arrVilla, $row_villa[0], $row_villa[1], $row_villa[2]); } // array values now are: Array ( [0] => Villa Hortensias [1] => 1 [2] => 5 [3] => Villa Hortensias [4] => 1 [5] => 42 [6] => Villa Costa [7] => 1 [8] => 8 [9] => Villa Costa [10] => 1 [11] => 12 [12] => Villa Costa [13] => 1 [14] => 20 [15] => Villa Costa [16] => 1 [17] => 51 ) print_r(array_values($arrVilla)); $id = 2; if (array_key_exists($id, $arrVilla)) { echo'
'; echo ''; echo ''; for ($weekId = 1; $weekId <= 52; $weekId++) { if ($weekId == $arrVilla[$id]) { echo ''; $id = $id + 3; if (!array_key_exists($id, $arrVilla)) { for ($weekId = $weekId; $weekId <= 51; $weekId++) { echo ''; } } } else { echo ''; } } echo''; echo'
weeknumber: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
' . $arrVilla[0] . '' . $arrVilla[$id] . '00
'; } ?> // output: // weeknumber: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 // Villa Hortensias 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 42 0 0 0 0 0 0 0 0 0 0 // now i want the other villa in the array also to print: Villa Costa, but i cant get it so far.