1 <? PHP 2 Session_start (); 3 // Define playing cards 4 $ Poker = Array ( 5 '123', '123', '123', '123', '123 ', 6 '123', '123', '123', '123', '123 ', 7 '123', '123', '123', '123', '123 ', 8 '123', '123', '123', '123', '123 ', 9 '15', '16' 10 ); 11 $ Microtime = Microtime ( True ); 12 13 // Cyclic Statistics 14 For ( $ I = 0; $ I <1, 500000; $ I ++ ) 15 { 16 $ A_player = $ B _player = Array (); // Initialize Players A and B 17 $ Fp = Array_rand ( $ Poker , 6 ); // Randomly draw six sheets 18 Foreach ( $ Fp As $ V ) 19 { 20 If ( Count ( $ A_player ) <3 ) 21 { 22 $ A_player [] = $ Poker [ $ V ]; // The first three images are sent to. 23 } 24 Else 25 { 26 $ B _player [] =$ Poker [ $ V ]; // The last three images are sent to B. 27 } 28 } 29 30 Three ( $ A_player , $ B _player ); // If a forms a double king 31 Three ($ B _player , $ A_player ); // If B forms a double king 32 } 33 34 // After the formation of three, compare with the other party 35 Function Three ( $ Var1 , $ Var2 ) 36 { 37 // Remove color information 38 For ( $ X = 0; $ X < Count ( $ Var1 ); $ X ++ ) 39 { 40 $ Var1 [$ X ] = Substr ( $ Var1 [ $ X ], 0, 2 ); 41 } 42 For ( $ Y = 0; $ Y < Count ( $ Var2 ); $ Y ++ ) 43 { 44 $ Var2 [ $ Y ] = Substr ( $ Var2 [ $ Y ], 0, 2 ); 45 } 46 47 // One Party pulls the double king 48 If ( Is_integer ( Array_search ("15 ", $ Var1 ))&& Is_integer ( Array_search ("16 ", $ Var1 ))) 49 { 50 If ( Count ( Array_count_values ($ Var2 ) = 1 ) 51 { 52 $ Player_other = Array_values ( Array_diff ( $ Var1 , Array (15, 16 ))); 53 If ( $ Player_other [0] =$ Var2 [0 ]) 54 { 55 $ _ Session ["Result"]. = "Shuang Wang _" ; 56 } 57 } 58 } 59 Else 60 { 61 // One Party only draws one king 62 If (( Is_integer ( Array_search ("15 ", $ Var1 ) | Is_integer ( Array_search ("16 ", $ Var1 )))&& Count ( Array_count_values ( Array_diff ( $ Var1 , Array (15, 16) = 1 ) 63 { 64 If (( Is_integer ( Array_search ("15 ", $ Var2 ) | Is_integer ( Array_search ("16 ", $ Var2 )))&&Count ( Array_count_values ( Array_diff ( $ Var2 , Array (15, 16) = 1 ) 65 { 66 $ Player_other1 = Array_values ( Array_diff ( $ Var1 , Array (15, 16 ))); 67 $ Player_other2 = Array_values ( Array_diff ( $ Var2 , Array (15, 16 ))); 68 If ( $ Player_other1 [0] = $ Player_other2 [0 ]) 69 { 70 $ _ Session ["Result"]. = "Dan Wang _" ; 71 } 72 } 73 } 74 // One Party pulls three hard lines 75 Elseif ( Count (Array_count_values ( $ Var1 ) = 1 ) 76 { 77 If ( Is_integer ( Array_search ("15 ", $ Var2 ))&& Is_integer ( Array_search ("16 ", $ Var2 ))) 78 { 79 $ Player_other = Array_values ( Array_diff ( $ Var2 , Array (15, 16 ))); 80 If ( $ Player_other [0] = $ Var1 [0 ]) 81 { 82 $ _ Session ["Result"]. = "three hard _" ; 83 } 84 } 85 } 86 } 87 } 88 Echo "Total execution :".$ _ Session ["Num"] ++. "comparison operation. A total { $ I } Times <br>" ; 89 Echo "Execution time :" ; 90 Echo Microtime ( True )- $ Microtime . "Seconds <br>" ; 91 Echo "Comparison result :".$ _ Session ["Result" ]; 92 93 94 95 ?> 96 97 <Meta http-equiv = "refresh" content = "15">