arrays - PHP get rid of all Aces after shuffled -


After altering 52 cards on the deck, what is the algorithm to get rid of all the aces? Where aces are not allowed in output results.

  & lt ;? Php function pc_array_shuffle ($ array) {$ i = count ($ array); While (- $ i) {$ j = mt_rand (0, $ i); If ($ i! = $ J) {// swap element $ tmp = $ array [$ j]; $ Array [$ j] = $ array [$ i]; $ Array [$ i] = $ tmp; }} Returned the $ array; } $ Suit = array ('club', 'diamond', 'heart', 'hook'); $ Card = array ('ace', 2, 3, 4, 5, 6, 7, 8, 9, 10, 'jack', 'queen', 'king'); $ Deck = PC_array_shuffle (category (1, 52)); $ N = 1; While (($ draw = array_pop ($ deck)) = null) {echo $ n. ')'. $ Cards [$ draw / 4] 'of' $ Suit [$ draw $ 4] '& lt; Br / & gt; '; $ N ++; }? & Gt;  

Give it a try:

< Ex> $ suit = array ('club', 'diamond', 'heart', 'hook'); $ Card = array ('ace', 2, 3, 4, 5, 6, 7, 8, 9, 10, 'jack', 'queen', 'king'); $ Deck = array (); $ No_aces = array (); // The forwarding of the card forwarding ($ card as the $ card) {foreach ($ suit $ suit) {$ deck [] = "card" of ". $ Suit; }} Shaphamal Dek - What did I do there? ;) Shuffle ($ deck); // Delete the equity foreach ($ deck as $ $ card) while adding a shuffled card to another array {$ pos = strrpos (strtolower ($ card), "Ace"); If ($ pos === incorrect) {// is not an Ace, then add $ $ to $ no_aces array $ $; }} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ Code>

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -