3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<? function main(){ $cards = array("ah", "ac", "ad", "as", "2h", "2c", "2d", "2s", "3h", "3c", "3d", "3s", "4h", "4c", "4d", "4s", "5h", "5c", "5d", "5s", "6h", "6c", "6d", "6s", "7h", "7c", "7d", "7s", "8h", "8c", "8d", "8s", "9h", "9c", "9d", "9s", "th", "tc", "td", "ts", "jh", "jc", "jd", "js", "qh", "qc", "qd", "qs", "kh", "kc", "kd", "ks"); srand(time()); for($i = 0; $i < 52; $i++) { $count = count($cards); $random = (rand()%$count); if($cards[$random] == "") { $i--; } else { $deck[] = $cards[$random]; $cards[$random] = ""; } } srand(time()); $starting_point = (rand()%51); print("Starting point for cut cards is: $starting_point<p>"); // display shuffled cards (EXAMPLE ONLY) for ($index = 0; $index < 52; $index++) { if ($starting_point == 52) { $starting_point = 0; } print("Uncut Point: <strong>$deck[$index]</strong> "); print("Starting Point: <strong>$deck[$starting_point]</strong><br>"); $starting_point++; } } main(); ?>
based on v9U9H
Output for 7.1.0
Starting point for cut cards is: 31<p>Uncut Point: <strong>9s</strong> Starting Point: <strong>as</strong><br>Uncut Point: <strong>ah</strong> Starting Point: <strong>qc</strong><br>Uncut Point: <strong>9c</strong> Starting Point: <strong>8d</strong><br>Uncut Point: <strong>kc</strong> Starting Point: <strong>3s</strong><br>Uncut Point: <strong>9h</strong> Starting Point: <strong>7h</strong><br>Uncut Point: <strong>9d</strong> Starting Point: <strong>5h</strong><br>Uncut Point: <strong>3c</strong> Starting Point: <strong>2c</strong><br>Uncut Point: <strong>ac</strong> Starting Point: <strong>8h</strong><br>Uncut Point: <strong>tc</strong> Starting Point: <strong>3d</strong><br>Uncut Point: <strong>3h</strong> Starting Point: <strong>7s</strong><br>Uncut Point: <strong>ad</strong> Starting Point: <strong>6h</strong><br>Uncut Point: <strong>jd</strong> Starting Point: <strong>jh</strong><br>Uncut Point: <strong>7c</strong> Starting Point: <strong>4c</strong><br>Uncut Point: <strong>kd</strong> Starting Point: <strong>4h</strong><br>Uncut Point: <strong>ts</strong> Starting Point: <strong>7d</strong><br>Uncut Point: <strong>8s</strong> Starting Point: <strong>ks</strong><br>Uncut Point: <strong>2d</strong> Starting Point: <strong>5d</strong><br>Uncut Point: <strong>jc</strong> Starting Point: <strong>kh</strong><br>Uncut Point: <strong>qs</strong> Starting Point: <strong>5s</strong><br>Uncut Point: <strong>8c</strong> Starting Point: <strong>4s</strong><br>Uncut Point: <strong>qd</strong> Starting Point: <strong>qh</strong><br>Uncut Point: <strong>4d</strong> Starting Point: <strong>9s</strong><br>Uncut Point: <strong>th</strong> Starting Point: <strong>ah</strong><br>Uncut Point: <strong>6c</strong> Starting Point: <strong>9c</strong><br>Uncut Point: <strong>js</strong> Starting Point: <strong>kc</strong><br>Uncut Point: <strong>6d</strong> Starting Point: <strong>9h</strong><br>Uncut Point: <strong>6s</strong> Starting Point: <strong>9d</strong><br>Uncut Point: <strong>2s</strong> Starting Point: <strong>3c</strong><br>Uncut Point: <strong>2h</strong> Starting Point: <strong>ac</strong><br>Uncut Point: <strong>td</strong> Starting Point: <strong>tc</strong><br>Uncut Point: <strong>5c</strong> Starting Point: <strong>3h</strong><br>Uncut Point: <strong>as</strong> Starting Point: <strong>ad</strong><br>Uncut Point: <strong>qc</strong> Starting Point: <strong>jd</strong><br>Uncut Point: <strong>8d</strong> Starting Point: <strong>7c</strong><br>Uncut Point: <strong>3s</strong> Starting Point: <strong>kd</strong><br>Uncut Point: <strong>7h</strong> Starting Point: <strong>ts</strong><br>Uncut Point: <strong>5h</strong> Starting Point: <strong>8s</strong><br>Uncut Point: <strong>2c</strong> Starting Point: <strong>2d</strong><br>Uncut Point: <strong>8h</strong> Starting Point: <strong>jc</strong><br>Uncut Point: <strong>3d</strong> Starting Point: <strong>qs</strong><br>Uncut Point: <strong>7s</strong> Starting Point: <strong>8c</strong><br>Uncut Point: <strong>6h</strong> Starting Point: <strong>qd</strong><br>Uncut Point: <strong>jh</strong> Starting Point: <strong>4d</strong><br>Uncut Point: <strong>4c</strong> Starting Point: <strong>th</strong><br>Uncut Point: <strong>4h</strong> Starting Point: <strong>6c</strong><br>Uncut Point: <strong>7d</strong> Starting Point: <strong>js</strong><br>Uncut Point: <strong>ks</strong> Starting Point: <strong>6d</strong><br>Uncut Point: <strong>5d</strong> Starting Point: <strong>6s</strong><br>Uncut Point: <strong>kh</strong> Starting Point: <strong>2s</strong><br>Uncut Point: <strong>5s</strong> Starting Point: <strong>2h</strong><br>Uncut Point: <strong>4s</strong> Starting Point: <strong>td</strong><br>Uncut Point: <strong>qh</strong> Starting Point: <strong>5c</strong><br>
Output for 5.4.0 - 7.0.14
Starting point for cut cards is: 44<p>Uncut Point: <strong>7h</strong> Starting Point: <strong>6h</strong><br>Uncut Point: <strong>9c</strong> Starting Point: <strong>4h</strong><br>Uncut Point: <strong>ts</strong> Starting Point: <strong>kh</strong><br>Uncut Point: <strong>ks</strong> Starting Point: <strong>jc</strong><br>Uncut Point: <strong>td</strong> Starting Point: <strong>5c</strong><br>Uncut Point: <strong>qd</strong> Starting Point: <strong>3s</strong><br>Uncut Point: <strong>tc</strong> Starting Point: <strong>6s</strong><br>Uncut Point: <strong>5s</strong> Starting Point: <strong>jh</strong><br>Uncut Point: <strong>jd</strong> Starting Point: <strong>7h</strong><br>Uncut Point: <strong>qs</strong> Starting Point: <strong>9c</strong><br>Uncut Point: <strong>ac</strong> Starting Point: <strong>ts</strong><br>Uncut Point: <strong>qc</strong> Starting Point: <strong>ks</strong><br>Uncut Point: <strong>6c</strong> Starting Point: <strong>td</strong><br>Uncut Point: <strong>7d</strong> Starting Point: <strong>qd</strong><br>Uncut Point: <strong>kc</strong> Starting Point: <strong>tc</strong><br>Uncut Point: <strong>3c</strong> Starting Point: <strong>5s</strong><br>Uncut Point: <strong>9d</strong> Starting Point: <strong>jd</strong><br>Uncut Point: <strong>7s</strong> Starting Point: <strong>qs</strong><br>Uncut Point: <strong>ad</strong> Starting Point: <strong>ac</strong><br>Uncut Point: <strong>9h</strong> Starting Point: <strong>qc</strong><br>Uncut Point: <strong>7c</strong> Starting Point: <strong>6c</strong><br>Uncut Point: <strong>ah</strong> Starting Point: <strong>7d</strong><br>Uncut Point: <strong>3d</strong> Starting Point: <strong>kc</strong><br>Uncut Point: <strong>8d</strong> Starting Point: <strong>3c</strong><br>Uncut Point: <strong>qh</strong> Starting Point: <strong>9d</strong><br>Uncut Point: <strong>2d</strong> Starting Point: <strong>7s</strong><br>Uncut Point: <strong>5h</strong> Starting Point: <strong>ad</strong><br>Uncut Point: <strong>3h</strong> Starting Point: <strong>9h</strong><br>Uncut Point: <strong>kd</strong> Starting Point: <strong>7c</strong><br>Uncut Point: <strong>2h</strong> Starting Point: <strong>ah</strong><br>Uncut Point: <strong>2s</strong> Starting Point: <strong>3d</strong><br>Uncut Point: <strong>8h</strong> Starting Point: <strong>8d</strong><br>Uncut Point: <strong>9s</strong> Starting Point: <strong>qh</strong><br>Uncut Point: <strong>4s</strong> Starting Point: <strong>2d</strong><br>Uncut Point: <strong>th</strong> Starting Point: <strong>5h</strong><br>Uncut Point: <strong>4d</strong> Starting Point: <strong>3h</strong><br>Uncut Point: <strong>8s</strong> Starting Point: <strong>kd</strong><br>Uncut Point: <strong>2c</strong> Starting Point: <strong>2h</strong><br>Uncut Point: <strong>6d</strong> Starting Point: <strong>2s</strong><br>Uncut Point: <strong>as</strong> Starting Point: <strong>8h</strong><br>Uncut Point: <strong>4c</strong> Starting Point: <strong>9s</strong><br>Uncut Point: <strong>5d</strong> Starting Point: <strong>4s</strong><br>Uncut Point: <strong>8c</strong> Starting Point: <strong>th</strong><br>Uncut Point: <strong>js</strong> Starting Point: <strong>4d</strong><br>Uncut Point: <strong>6h</strong> Starting Point: <strong>8s</strong><br>Uncut Point: <strong>4h</strong> Starting Point: <strong>2c</strong><br>Uncut Point: <strong>kh</strong> Starting Point: <strong>6d</strong><br>Uncut Point: <strong>jc</strong> Starting Point: <strong>as</strong><br>Uncut Point: <strong>5c</strong> Starting Point: <strong>4c</strong><br>Uncut Point: <strong>3s</strong> Starting Point: <strong>5d</strong><br>Uncut Point: <strong>6s</strong> Starting Point: <strong>8c</strong><br>Uncut Point: <strong>jh</strong> Starting Point: <strong>js</strong><br>
Output for 4.3.0 - 5.3.29
<? function main(){ $cards = array("ah", "ac", "ad", "as", "2h", "2c", "2d", "2s", "3h", "3c", "3d", "3s", "4h", "4c", "4d", "4s", "5h", "5c", "5d", "5s", "6h", "6c", "6d", "6s", "7h", "7c", "7d", "7s", "8h", "8c", "8d", "8s", "9h", "9c", "9d", "9s", "th", "tc", "td", "ts", "jh", "jc", "jd", "js", "qh", "qc", "qd", "qs", "kh", "kc", "kd", "ks"); srand(time()); for($i = 0; $i < 52; $i++) { $count = count($cards); $random = (rand()%$count); if($cards[$random] == "") { $i--; } else { $deck[] = $cards[$random]; $cards[$random] = ""; } } srand(time()); $starting_point = (rand()%51); print("Starting point for cut cards is: $starting_point<p>"); // display shuffled cards (EXAMPLE ONLY) for ($index = 0; $index < 52; $index++) { if ($starting_point == 52) { $starting_point = 0; } print("Uncut Point: <strong>$deck[$index]</strong> "); print("Starting Point: <strong>$deck[$starting_point]</strong><br>"); $starting_point++; } } main(); ?>