1、mkdir()创建多级目录的时候需要将第三个参数设置为true
- 说明
bool mkdir ( string $pathname [, int $mode = 0777 [, bool $recursive = false [, resource $context ]]] )
2、strtotime() add months
$birthdate = "2010-1-1";
$waydate = date('Y-m-d', strtotime('+6 months', strtotime($birthdate)));
3、array_search()
array_search — 在数组中搜索给定的值,如果成功则返回首个相应的键名
4、sprintf
sprintf — Return a formatted string
echo sprintf("%'.9d\n", 123);
echo sprintf("%'.09d\n", 123);
echo sprintf("%1$09d\n", 123);
echo sprintf("09d\n", 123);
5、str_pad
str_pad — 使用另一个字符串填充字符串为指定长度
$input = "Alien";
echo str_pad($input, 10);
echo str_pad($input, 10, "-=", STR_PAD_LEFT);
echo str_pad($input, 10, "_", STR_PAD_BOTH);
echo str_pad($input, 6, "___");
echo str_pad($input, 3, "*");
6、iconv解决中文排序问题
$collection->sortBy(function ($item) {
return iconv('utf8','GBK',$item->name);
})->values();