* @copyright 2021 Bartolomé Sintes Marco * @license http://www.gnu.org/licenses/agpl.txt AGPL 3 or later * @version 2021-12-02 * @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 . */ // Se accede a la sesión session_name("cartas-1"); session_start(); if (!isset($_SESSION["baraja"])) { $_SESSION["baraja"] = []; foreach (["p", "c", "d", "t"] as $palo) { for ($i = 1; $i <= 13; $i++) { $_SESSION["baraja"][] = "$palo$i"; } } shuffle($_SESSION["baraja"]); $_SESSION["picas"] = []; $_SESSION["corazones"] = []; $_SESSION["diamantes"] = []; $_SESSION["treboles"] = []; } ?> Distribuye cartas. Juegos de cartas (1). Sesiones. Ejercicios. PHP. Bartolomé Sintes Marco. www.mclibre.org

Distribuye cartas

Haga clic en los botones para añadir la carta a uno de los montones:

\n"; print " \n"; print " \n"; if (count($_SESSION["baraja"]) > 0) { $carta = $_SESSION["baraja"][count($_SESSION["baraja"]) - 1]; print " \"$carta\"\n"; } else { print " 😀\n"; } print " \n"; print " \n"; print " \n"; foreach ($_SESSION["picas"] as $carta) { print " \"$carta\"\n"; } print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; foreach ($_SESSION["corazones"] as $carta) { print " \"$carta\"\n"; } print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; foreach ($_SESSION["diamantes"] as $carta) { print " \"$carta\"\n"; } print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; foreach ($_SESSION["treboles"] as $carta) { print " \"$carta\"\n"; } print " \n"; print " \n"; print " \n"; ?>