3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // Declare the suits $suits = array ( "Spades", "Hearts", "Clubs", "Diamonds" ); // Declare the faces $faces = array ( "Two"=>2, "Three"=>3, "Four"=>4, "Five"=>5, "Six"=>6, "Seven"=>7, "Eight"=>8, "Nine"=>9, "Ten"=>10, "Jack"=>10, "Queen"=>10, "King"=>10, "Ace"=>11 ); // create deck array // get all suits which has foreach($suits as $suit) { // get all the keys frok faces // now $keys = array_key($faces); // loop through the keys as faces foreach ($keys as $face) { // declare the deck array $deck = ['face' => $face, 'suit' => $suit]; var_dump($deck); } foreach($faces as $face => $value) { $deck = ['face' => $face, 'suit' => $suit ]; } var_dump($deck); }
based on UHJ4k
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to undefined function array_key() in /in/SmM55:25 Stack trace: #0 {main} thrown in /in/SmM55 on line 25
Process exited with code 255.
Output for 5.4.0 - 5.6.28
Fatal error: Call to undefined function array_key() in /in/SmM55 on line 25
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/SmM55 on line 30
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/SmM55 on line 30
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/SmM55 on line 30
Process exited with code 255.