Created
June 2, 2012 07:15
-
-
Save ksomemo/2857108 to your computer and use it in GitHub Desktop.
カードの振り分けの実装
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CardManager { | |
/** | |
* | |
* @param integer $deal_num | |
* @param String $card | |
* | |
* @return array | |
*/ | |
public function deal($deal_num, $card) | |
{ | |
$result = array_fill(0, $deal_num, ''); | |
$len = strlen($card); | |
$roop = $len - ($len % $deal_num); | |
for ($i = 0; $i < $roop; $i++) { | |
$index = $i % $deal_num; | |
$result[$index] .= substr($card, $i, 1); | |
} | |
return $result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment