如果我从数据库中名为image_store
的列中获取数据,例如:
/web/images/data/firstImage.png
/web/images/data/secondImage.png
/web/images/data/thirdImage.png
我想填充一个setImage函数,该函数将/data/
之后的字符串设置为fileName,将/firstImage.png
之前的字符串设置为目录,例如:
$this->setImage('firstImage.png', '/web/images/data/')
有没有办法可以从我从数据库中找回的字符串中获取所需的信息?
答案 0 :(得分:1)
是的,只需使用 $timenow = time();
$start_time = strtotime('+15 minutes', $timenow);
// round to next 15 minutes (15 * 60 seconds)
$start_time = ceil($start_time / (5 * 60)) * (5 * 60);
//set the start times
$opentime = strtotime('10:00');
$closetime = strtotime('11:55');
// get a list of prebooked slots from database
$time_slots = $this->countStartTimes();
$available_slots = array();
while($start_time <= $closetime && $start_time >= $opentime) {
$key = date('H:i', $start_time);
if(array_key_exists($key, $time_slots)) {
if($time_slots[$key] == SLOTS) {
$available_slots[] = 'FULL';
break;
}
}
$available_slots[] = date('H:i', $start_time);
$start_time = strtotime('+5 minutes', $start_time);
}
个功能和explode/implode
自行获取图片名称:
array_pop()
这适用于任何深度的url路径。