与Laravel系列合作,我的头疼.我有两个集合:
$dt = Carbon::now();
$days = new Collection([]);
/**
* Create a calender month
*/
for ($day = 1; $day <= $dt->daysInMonth; $day++) {
$date = Carbon::create($dt->year, $dt->month, $day)->toDateString();
$days->push(new Timesheet([
'date' => $date,
]));
}
/**
* Get all timesheets for user
*/
$timesheets = Timesheet::where('user_id', $this->user->id)
->get();
Run Code Online (Sandbox Code Playgroud)
\Illuminate\Database\Eloquent\Collection($timesheets)
#attributes: array:5 [?
"id" => "1"
"user_id" => "1"
"date" => "2016-02-22 22:05:01"
"created_at" => "2016-02-22 22:05:01"
"updated_at" => "2016-02-22 22:05:01"
]
// ... one or more …Run Code Online (Sandbox Code Playgroud) 如何对这些 URI 进行模式匹配?我需要字符串匹配第一个和第二个斜杠 (1) 之间的任何字符或第一个斜杠 (2) 或 (3) 之后出现的任何字符/。
请注意第一个示例中的尾部斜杠。
(1)
/resource/_another-resource
(2)
/_resource
(3)
/
我有uri_resource = uri:match('^%/(.-)%/')它处理示例 1,但如果不存在尾随斜杠,则会失败。