* @copyright 2021 Bartolomé Sintes Marco * @license http://www.gnu.org/licenses/agpl.txt AGPL 3 or later * @version 2022-01-08 * @link https://www.mclibre.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ // AVISO: // Este programa crea dos matrices y va pasando las cartas de una a otra matriz. // Se podría hacer lo mismo con una sola matriz y guardando un número (el número // de crtas que se enseñan). // Se accede a la sesión session_name("cartas-5"); session_start(); if (!isset($_SESSION["baraja"]) || !isset( $_SESSION["cartas"])) { $_SESSION["baraja"] = []; foreach (["c", "d", "p", "t"] as $palo) { for ($i = 1; $i <= 13; $i++) { $_SESSION["baraja"][] = "$palo$i"; } } shuffle($_SESSION["baraja"]); $_SESSION["cartas"] = []; } ?> Muestra cartas. Juegos de cartas (1). Sesiones. Ejercicios. PHP. Bartolomé Sintes Marco. www.mclibre.org

Muestra y oculta cartas

Haga clic en los botones para mostrar una carta menos, reiniciar o mostrar una carta más:

\n"; print " \"dorso\"\n"; foreach ($_SESSION["cartas"] as $carta) { print " \"$carta\"\n"; } print "

\n"; ?>