americano code snipets - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of americano code snipets.php
- <?php
- $players = ['Paquito', 'Bela', 'Gutierrez', 'Lebron', 'Silingo', 'Galan', 'Chingotto', 'Tapia', '9', '10', '11', '12'];
- $combo = [];
- $totalPlayers = sizeof($players);
- foreach ($players as $k => $p) {
- foreach ($players as $fp) {
- if ($p == $fp) {
- continue;
- }
- $string = "$p&$fp";
- $data = [
- 'player1' => $p,
- 'player2' => $fp,
- ];
- array_push($combo, $data);
- }
- array_splice($players, 0, 1);
- }
- //return $combo;
- $matchs = [];
- $roundedMatches = [];
- foreach ($combo as $k => $player) {
- foreach ($combo as $m => $player2) {
- if (!in_array($player2['player1'], $matchs) && !in_array($player2['player2'], $matchs)) {
- array_push($matchs, $player2['player1']);
- array_push($matchs, $player2['player2']);
- unset($combo[$m]);
- }
- if (count($matchs) == $totalPlayers) {
- array_push($roundedMatches, $matchs);
- $matchs = [];
- }
- }
- }
- print_r($roundedMatches);
File Description
- americano code snipets
- PHP Code
- 31 Dec-2020
- 1.28 Kb
You can Share it:
Latest PHP Pastes