Skip to content

Instantly share code, notes, and snippets.

@kkeeth
Last active April 4, 2017 02:46
Show Gist options
  • Select an option

  • Save kkeeth/423c9786b8f0ccc3f854ebc58def1446 to your computer and use it in GitHub Desktop.

Select an option

Save kkeeth/423c9786b8f0ccc3f854ebc58def1446 to your computer and use it in GitHub Desktop.
PHPのスニペット
<?php
// 変数内の改行コードを空白に変更
$text = str_replace(array("\r\n","\r","\n"), ' ', $text);
// 正規表現での整数チェック
preg_match("/^[+-]?[0-9]+$/", $check, $result);
// 1ヵ月後の第○週 第○曜日の日付を取得
$subscribe_week_day: 第○曜日(数字指定)
$subscribe_week: 第○週
$year = date('Y');
$month = date('m', strtotime('+1 month'));
$first_day = date('w', mktime(0, 0, 0, $month, 1, $year));
$day = $subscribe_week_day - $first_day + 1;
if($day <= 0) $day += 7;
$day += 7 * ($subscribe_week - 1);
$next_date = date('Y-m-d', mktime(0, 0, 0, $month, $day, $year));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment