Viendo el codigo de: ../codigoPHP/ejercicio16.php
⬅ Volver al inicio
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ejercicio 16</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Bodoni+Moda:ital,opsz,wght@0,6..96,400..900;1,6..96,400..900&family=Inter:wght@400;500;600;700;800&family=UnifrakturMaguntia&display=swap" rel="stylesheet">
<link rel="stylesheet" href="../../webroot/css/styles.css">
<link rel="stylesheet" href="../webroot/css/estilos.css">
<style>
.enlace-volver {
color: #474a8a;
font-weight: bold;
text-decoration: none;
display: inline-block;
margin-bottom: 20px;
}
.container {
display: block;
margin: 0 auto;
background: white;
padding: 30px;
border-radius: 8px;
max-width: 900px;
width: 100%;
text-align: left;
}
.container h2 {
color: #777bb4;
margin-top: 30px;
margin-bottom: 15px;
border-bottom: 2px solid #e9ecef;
padding-bottom: 10px;
}
.container h3 {
color: #474a8a;
margin-top: 25px;
}
</style>
</head>
<body class="pagina-ajustada">
<header id="site-header" class="cabecera">
<div class="cabecera__contenedor">
<img class="monograma" src="../../webroot/images/cruz.png" alt="">
<h1 class="titulo-header">TEMA 3: Características del Lenguaje PHP</h1>
<img class="monograma" src="../../webroot/images/cruz.png" alt="">
</div>
</header>
<main>
<section>
<div class="container">
<a href='../indexProyectoTema3.php' class='enlace-volver'>⬅ Volver al inicio</a>
<hr>
<?php
/*
* Moisés Alberto Dominguez Cruz
* 07/10/2026
* 16. Recorrer el array anterior utilizando funciones para obtener el mismo resultado.
*/
$aSueldoDiasSemana = [
"LUNES" => 80,
"MARTES" => 90,
"MIERCOLES" => 56,
"JUEVES" => 70,
"VIERNES" => 10,
"SABADO" => 67,
"DOMINGO" => 100
];
echo "<h3>Sueldos por dias</h3><ul>";
// reset() coloca el puntero interno en el primer elemento del array
reset($aSueldoDiasSemana);
// key() devuelve null cuando el puntero pasa del ultimo elemento.
// Se compara con !== porque con != una clave 0 tambien se consideraria igual a null y el bucle pararia
while (key($aSueldoDiasSemana) !== null) {
echo '<li>el ' . key($aSueldoDiasSemana) . ' se cobra ' . current($aSueldoDiasSemana) . '</li>';
// next() avanza el puntero al siguiente elemento
next($aSueldoDiasSemana);
}
// array_sum() suma todos los valores del array, el mismo total que en el ejercicio 15
echo '</ul><p>Pago total de la semana ' . array_sum($aSueldoDiasSemana) . '</p>';
?>
</div>
</section>
</main>
<footer class="pie">
<div class="pie__redes">
<a class="pie__red" href="../indexProyectoTema3.php" title="Ir al índice del Tema 3" aria-label="Ir al índice del Tema 3">
<img src="../../webroot/images/icons/casa.png" alt="">
</a>
<a class="pie__red" href="https://github.com/moisesdcsauces/MDCDWESProyectoTema3" target="_blank" rel="noopener" aria-label="GitHub">
<img src="../../webroot/images/icons/github.png" alt="">
</a>
<a class="pie__red" href="https://www.linkedin.com/in/mois%C3%A9s-alberto-dom%C3%ADnguez-cruz/" target="_blank" rel="noopener" aria-label="LinkedIn">
<img src="../../webroot/images/icons/linkedin.png" alt="">
</a>
</div>
<p class="pie__texto">© <a class="titulo-enlace" href="../../index.html"> Moisés Alberto Domínguez Cruz</a> - IES Los Sauces<span id="year"></span></p>
</footer>
<script src="../../webroot/js/main.js" defer></script>
</body>
</html>