本文整理汇总了PHP中October\Rain\Router\Helper::segmentIsWildcard方法的典型用法代码示例。如果您正苦于以下问题:PHP Helper::segmentIsWildcard方法的具体用法?PHP Helper::segmentIsWildcard怎么用?PHP Helper::segmentIsWildcard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类October\Rain\Router\Helper
的用法示例。
在下文中一共展示了Helper::segmentIsWildcard方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: captureWildcardSegments
/**
* Captures and removes every segment of a URL after a wildcard
* pattern segment is detected, until both collections of segments
* are the same size.
* @param array $urlSegments
* @return array
*/
protected function captureWildcardSegments(&$urlSegments)
{
$wildSegments = [];
$patternSegments = $this->segments;
$segmentDiff = count($urlSegments) - count($patternSegments);
$wildMode = false;
$wildCount = 0;
foreach ($urlSegments as $index => $urlSegment) {
if ($wildMode) {
if ($wildCount < $segmentDiff) {
$wildSegments[] = $urlSegment;
$wildCount++;
unset($urlSegments[$index]);
continue;
} else {
break;
}
}
$patternSegment = $patternSegments[$index];
if (Helper::segmentIsWildcard($patternSegment)) {
$wildMode = true;
}
}
// Reset array index
$urlSegments = array_values($urlSegments);
return $wildSegments;
}