Created
March 15, 2013 06:18
-
-
Save haruta/5167828 to your computer and use it in GitHub Desktop.
This file contains 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 YmLinerTest | |
{ | |
public function test(array $array) | |
{ | |
sort($array);//一応ソート | |
$date = new DateTime($array[0].'01'); | |
foreach ($array as $ym) { | |
if ($date->format('Ym') != $ym) return false; | |
$date->modify('+1 month'); | |
} | |
return true; | |
} | |
} | |
$tester = new YmLinerTest(); | |
var_dump($tester->test(array("201301", "201302", "201303"))); | |
var_dump($tester->test(array("201301", "201302", "201304"))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
続けるにはENTERを押すかコマンドを入力してください
bool(true)
bool(false)