1 | <?php |
2 | |
3 | require_once __DIR__ . "/../lib/php/devuelveJson.php"; |
4 | require_once __DIR__ . "/../lib/php/devuelveErrorInterno.php"; |
5 | |
6 | try { |
7 | |
8 | $lista = [ |
9 | [ |
10 | "nombre" => "pp", |
11 | "color" => "azul" |
12 | ], |
13 | [ |
14 | "nombre" => "qk", |
15 | "color" => "rojo" |
16 | ], |
17 | [ |
18 | "nombre" => "tt", |
19 | "color" => "rosa" |
20 | ], |
21 | [ |
22 | "nombre" => "bb", |
23 | "color" => "azul" |
24 | ] |
25 | ]; |
26 | |
27 | |
28 | $render = ""; |
29 | foreach ($lista as $modelo) { |
30 | |
31 | |
32 | |
33 | $nombre = htmlentities($modelo["nombre"]); |
34 | $color = htmlentities($modelo["color"]); |
35 | $render .= |
36 | "<dt>{$nombre}</dt> |
37 | <dd>{$color}</dd>"; |
38 | } |
39 | |
40 | devuelveJson(["lista" => ["innerHTML" => $render]]); |
41 | } catch (Throwable $error) { |
42 | |
43 | devuelveErrorInterno($error); |
44 | } |
45 | |