本文整理汇总了PHP中FSS_Helper::stringStartsWith方法的典型用法代码示例。如果您正苦于以下问题:PHP FSS_Helper::stringStartsWith方法的具体用法?PHP FSS_Helper::stringStartsWith怎么用?PHP FSS_Helper::stringStartsWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FSS_Helper
的用法示例。
在下文中一共展示了FSS_Helper::stringStartsWith方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Match
function Match($line, $lines, $offset)
{
$line = trim($line);
if ($line == "") {
return false;
}
$match = false;
// check for any starts with
if (count($this->starts) > 0) {
foreach ($this->starts as $starts) {
if (FSS_Helper::stringStartsWith($line, $starts)) {
$match = true;
}
}
}
// check for any regular expressions
if (count($this->regex) > 0) {
foreach ($this->regex as $regex) {
if (preg_match("/" . $regex . "/i", $line)) {
$match = true;
}
}
}
// no match found, so done
if (!$match) {
return false;
}
// have a match, if there are any nearby clauses, check them all
if (count($this->nearby) > 0) {
foreach ($this->nearby as $nearby) {
// setup default lines before and after
if (empty($nearby->lines)) {
$nearby->lines = 3;
}
if (empty($nearby->before)) {
$nearby->before = $nearby->lines;
}
if (empty($nearby->after)) {
$nearby->after = $nearby->lines;
}
// if there is a regex in the nearby, check it
if (isset($nearby->regex)) {
// create new match class
$test = new TrimMatch();
$test->regex[] = $nearby->regex;
// work out which lines
$start = max(0, $offset - $nearby->before);
$end = min(count($lines) - 1, $offset + $nearby->after);
$found = false;
// check each line
for ($i = $start; $i <= $end; $i++) {
$subline = trim($lines[$i]);
if ($test->Match($subline, $lines, $i)) {
$found = true;
break;
}
}
// if its not found, we failed for this line
if (!$found) {
return false;
}
}
}
}
return true;
}