How to create a multi foreach in Blank (wkhtmltopdf)

The desired result first, that’s what I want as pdf.

I use wkhtml in blank application.
But I have a problem with multi foreach in secound level. I get an error if I use this
$content .= ‘’.$values[‘geb_id’].’’;

Error:
grafik

And this is the part with entire foreach so far:

foreach($report as $key => $value){
if($key==0 || !empty($gebaeude_new) ){
$content .= ‘’;
$content .= ‘’.$value[‘geb_name’].’’;
$content .= ‘’;
}

			/*
			// NOT WHAT I WANT, BUT GOES
			foreach($value as $key2 => $values){
				if($key2!="geb_name"){
					$content .= '<td scope="col" class="dontBreak" style="color:blue">'.$values.'</td>';
				}
			*/

			// IF I USE $value['geb_id'] THAN LISTS THE ROOMS AS OFTEN AS THERE'RE ROOMS IN AN APPARTMENT. IT'S NOT WHAT I WANT
			// IF I USE $values['geb_id'] I GET AN ERROR

			foreach($value as $key2 => $values){
					$content .= '<tr>';
					$content .= '<td scope="row" class="dontBreak">'.$values['geb_id'].'</td>';
					$content .= '<td scope="row" class="dontBreak">'.$values['geb_name'].'</td>';
					$content .= '<td scope="row" class="dontBreak">'.$values['nutz_id'].'</td>';
					$content .= '<td scope="row" class="dontBreak">'.$values['nutz_einheit'].'</td>';
					$content .= '<td scope="row" class="dontBreak">'.$values['raum_id'].'</td>';
					$content .= '<td scope="row" class="dontBreak">'.$values['raum_name'].'</td>';
					$content .= '</tr>';
				}
			 }     

Has someone an idea?

Te paso un ejemplo de como puedes recorrer un foreach anidado,lo puedes adaptar a tu necesidad.

$SQL_Q=“SELECT idmenu, titulo, descripcion, link, clase, imagen, id , codigomenu
FROM tab_menu
WHERE rucemisor =”.sc_sql_injection($G_rucemisor) . " AND
grupo_id= “.sc_sql_injection($id_grupo). " AND
permiso=”.sc_sql_injection(1);

sc_lookup(ds,$SQL_Q);

if ({ds} === false){
	sc_alert( "Error de acceso. Mensaje = ". {ds_erro});
}elseif (empty ({ds})){
	sc_alert("Menu no existe.");
}else{	
	foreach({ds} as $key=>$menu) {
		$titulo_a=['idmenu'	=> $menu[0], 
				   'titulo'	=> $menu[1],
				   'link'	=> $menu[2],
				   'id'		=> $menu[6],
				   'permiso'=> $menu[4],
				   'imagen'	=> $menu[5]];

		$vcodimenu	= $menu[7];

		if( $menu[1]<>'Seguridad'){

			$_SESSION['MENUCARD'][$a] =$titulo_a;


			$SQL_M = "SELECT idsubmenu, idmenu, descripcion, links, id, permiso
							FROM tab_submenu 
								  WHERE rucemisor =" . sc_sql_injection($G_rucemisor) . "  AND 
										grupo_id= ".sc_sql_injection($id_grupo). "  AND  
										permiso= " .sc_sql_injection(1). " AND 
										idmenu=" . sc_sql_injection($vcodimenu);


			sc_lookup(rs,$SQL_M);
			if ({rs} === false){
				sc_alert( "Error de acceso. Mensaje = ". {rs_erro});
			}elseif (empty ({rs})) {

			}else {
				foreach({rs} as $sub=>$opcion){
					$sm_idsubmenu	= $opcion[0];
					$sm_idmenu		= $opcion[1];
					$sm_descripcion	= $opcion[2];
					$sm_links		= $opcion[3];
					$sm_id			= $opcion[4];
					$sm_permiso		= $opcion[5];
					$titulo_b=[
						'idsubmenu'    	=> $sm_idsubmenu,
						'subidmenu'    	=> $sm_idmenu,
						'subdescrip'    => $sm_descripcion,	
						'sublink'   	=> $sm_links,	
						'subid'    		=> $sm_id,
						'subpermiso'    => $sm_permiso
					];
					$_SESSION['MENUCARD'][$a][$b] =$titulo_b;
					$b++;
				}
				$b=0;
			}
		}
		$a++;
	}	
}

Saludos,
Fidel Torres
Lima-Perú

Revisa este codigo!

foreach($value as $key2 => $values) {
if ($key2 != “geb_name”) {
// Primer foreach: para manejar las filas y celdas de la tabla
$content .= ‘’ . htmlspecialchars($values) . ‘’;
}

// Segundo foreach anidado: para recorrer los valores dentro de $values si es un array
if (is_array($values)) {
    foreach($values as $key3 => $valueDetail) {
        // Aquí puedes procesar cada $valueDetail si es necesario
        $content .= '<tr>';
        $content .= '<td scope="row" class="dontBreak">' . (isset($valueDetail['geb_id']) ? $valueDetail['geb_id'] : '') . '</td>';
        $content .= '<td scope="row" class="dontBreak">' . (isset($valueDetail['geb_name']) ? $valueDetail['geb_name'] : '') . '</td>';
        $content .= '<td scope="row" class="dontBreak">' . (isset($valueDetail['nutz_id']) ? $valueDetail['nutz_id'] : '') . '</td>';
        $content .= '<td scope="row" class="dontBreak">' . (isset($valueDetail['nutz_einheit']) ? $valueDetail['nutz_einheit'] : '') . '</td>';
        $content .= '<td scope="row" class="dontBreak">' . (isset($valueDetail['raum_id']) ? $valueDetail['raum_id'] : '') . '</td>';
        $content .= '<td scope="row" class="dontBreak">' . (isset($valueDetail['raum_name']) ? $valueDetail['raum_name'] : '') . '</td>';
        $content .= '</tr>';
    }
}

}

Hello Fidel,
Thank you very much for your help!
I have transferred your suggestion to my project. Unfortunately, I get an error. The variables a and b (“Undefined variable”) are not recognized. Grateful if you have a look at.
Here’s my code:
$SQL_Q = "SELECT geb_gebaeude_id, Bezeichnung, Strasse, PLZ, Ort FROM geb_gebaeude ";
sc_lookup(ds,$SQL_Q);

				if ({ds} === false){ sc_alert( "Error de acceso. Mensaje = ". {ds_erro}); } 
				elseif (empty ({ds})) { sc_alert("Menu no existe."); }
				else {	
					foreach({ds} as $key=>$geb) {
						$gebaeude_a = ['idgeb'		=> $geb[0], 
									'bezeichnung'	=> $geb[1],
									'strasse'		=> $geb[2],
									'plz'			=> $geb[3],
									'ort'			=> $geb[4]
									];
						
							$_SESSION['GEBAEUDE'][$a] = $gebaeude_a;

							$SQL_M =	"SELECT geb_nutzeinheit_id, gebaeude_id, Bezeichnung, Nummer FROM geb_nutzeinheit ";
									sc_lookup(rs,$SQL_M);

							if ({rs} === false) { sc_alert( "Error de acceso. Mensaje = ". {rs_erro}); }
							elseif (empty ({rs})) { sc_alert("Menu no existe."); } 
							else {
								// hier nochmal gucken!
								foreach({rs} as $key1=>$ne){
									$ne_id			= $ne[0];
									$ne_idgeb		= $ne[1];
									$ne_bezeichnung	= $ne[2];
									$ne_nummer		= $ne[3];
									$gebaeude_b	= [
										'geb_nutzeinheit_id'    => $ne_id,
										'gebaeude_id'    		=> $ne_idgeb,
										'Bezeichnung'    		=> $ne_bezeichnung,	
										'Nummer'   				=> $ne_nummer	
									];
									$_SESSION['GEBAEUDE'][$a][$b] = $gebaeude_b;
									$b++;
									}

								$b=0;
							}
						$a++;
					}	
				}

Thanks!