本文整理汇总了PHP中StringHelper::explode方法的典型用法代码示例。如果您正苦于以下问题:PHP StringHelper::explode方法的具体用法?PHP StringHelper::explode怎么用?PHP StringHelper::explode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringHelper
的用法示例。
在下文中一共展示了StringHelper::explode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: between
public static function between($string, $start, $end)
{
$a = StringHelper::explode($string, $start);
if (count($a) >= 2) {
$a = $a[1];
$b = StringHelper::explode($a, $end);
if (count($b) >= 1) {
return $b[0];
}
}
return "";
}
示例2: run
private function run()
{
$url = "/";
if (isset($_GET["url"])) {
$url = "/" . $_GET["url"];
}
if (!(substr($url, strlen($url) - 1, 1) == "/")) {
$url .= "/";
}
$hit = false;
foreach ($this->routes as $route) {
if (preg_match("/" . $route->regex . "/", $url)) {
if (is_callable($route->result)) {
$hit = true;
call_user_func($route->result);
break;
}
if (is_object($route->result)) {
if (isset($route->result->filter)) {
$filters = StringHelper::explode($route->result->filter, "|");
$break = false;
foreach ($filters as $filter) {
$name = $filter;
$params = array();
if (strpos($filter, ":")) {
$name = substr($filter, 0, strpos($filter, ":", 1));
$params = StringHelper::between($filter, "(", ")");
$params = explode(",", $params);
foreach ($params as $i => $param) {
$params[$i] = StringHelper::between($param, "'", "'");
}
}
if (isset($this->filters[$name])) {
if (!call_user_func_array($this->filters[$name], $params)) {
$hit = true;
ErrorHelper::notFound("Filter error (" . $name . ")");
$break = true;
break;
}
} else {
$hit = true;
ErrorHelper::notFound("Filter not found");
$break = true;
break;
}
}
if ($break) {
break;
}
}
if (isset($route->result->view)) {
if (is_string($route->result->view)) {
$parts = explode("::", $route->result->view);
if (count($parts) == 2) {
$class = $parts[0];
$method = $parts[1];
if (file_exists(ROOT . "/game/views/" . strtolower($class) . ".php")) {
require_once ROOT . "/game/views/" . strtolower($class) . ".php";
$class .= "View";
$view = new $class();
if (method_exists($view, $method)) {
$hit = true;
$view->{$method}();
break;
}
}
}
}
if (is_callable($route->result->view)) {
$hit = true;
call_user_func($route->result->view);
break;
}
}
ErrorHelper::notFound("Page not found.");
}
}
}
if (!$hit) {
ErrorHelper::notFound("Page not found.");
}
}