Skip to content

Instantly share code, notes, and snippets.

@haruta
Created March 15, 2013 06:18
Show Gist options
  • Select an option

  • Save haruta/5167828 to your computer and use it in GitHub Desktop.

Select an option

Save haruta/5167828 to your computer and use it in GitHub Desktop.
<?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")));
@haruta
Copy link
Copy Markdown
Author

haruta commented Mar 15, 2013

続けるにはENTERを押すかコマンドを入力してください
bool(true)
bool(false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment