ユーザ用ツール

サイト用ツール

Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/lei_wiki/data/cache/3/3f5da508b8ab19516f62b36feb10e5d1.i failed
Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.
Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/lei_wiki/data/cache/3/3f5da508b8ab19516f62b36feb10e5d1.metadata failed

よく使うphpのその5
Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/lei_wiki/data/cache/3/3f5da508b8ab19516f62b36feb10e5d1.i failed
Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.
Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/lei_wiki/data/cache/3/3818fb8a3640a685899f60f313ecc849.i failed
Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.
Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/lei_wiki/data/cache/3/3818fb8a3640a685899f60f313ecc849.metadata failed
Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/lei_wiki/data/cache/3/3f5da508b8ab19516f62b36feb10e5d1.xhtml failed

数字から時間の変換

文字列の最後一文字削除

配列で作った最後の「,」削除

$foo = "abc,def,ghi,";
echo substr($foo, 0, -1);

文字コードの変換と空白削除とカンマの変換

 foreach($Data as $key => $val){
   foreach($val as $k2 => $v2){
     $value = trim(mb_convert_kana($v2,"s","EUC-JP"));
     $row[$key][$k2] = preg_replace("/,/",".",$value);
   }
 }

sprintfを使って文字変換

$url = "http://enjoy-lei.com/index.php?p=%d&t=%s";
$dUrl = sprintf($url, '5', "検索");
echo $dUrl;

翌月の計算

2012-03-31など使って翌月の計算は誤算される可能性がとても高いため、~ 必ず、1日から月の計算したほうがいい。

echo '先月 => '. date('m', strtotime(date('Y-m-1').' -1 month')) .'<br>';
echo '今月 => '. date('m') .'<br>';
echo '翌月 => '. date('m', strtotime(date('Y-m-1').' +1 month')) .'<br>';

結果 —

前月 => 10
今月 => 11
翌月 => 12

—-

よく使うphpのその5.txt · 最終更新: 2013/11/28 10:59 by luis_lee