当前位置: 首页>>代码示例>>PHP>>正文


PHP array_last函数代码示例

本文整理汇总了PHP中array_last函数的典型用法代码示例。如果您正苦于以下问题:PHP array_last函数的具体用法?PHP array_last怎么用?PHP array_last使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了array_last函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkArrayDifference

 /**
  * To Compare the array of items to find any changes are happened.
  *
  * @param array $source1 Set Of Array on Before Changes
  * @param array $source2 Set Of Array on After Changes
  * @param string $search type of search
  * @return bool True No Difference | False Has Difference
  */
 public static function checkArrayDifference($source1, $source2, $search)
 {
     if (count($source1) == 0 and count($source2) == 0) {
         return true;
     }
     if ($search == 'all') {
         loop:
         if (count($source1) == 0) {
             return true;
         }
         if (count($source1) != count($source2)) {
             return false;
         }
         $last_bfr = array_last($source1);
         $last_aft = array_last($source2);
         if (!empty(array_diff($last_bfr, $last_aft))) {
             return false;
         } else {
             array_pop($source1);
             array_pop($source2);
             goto loop;
         }
     }
     return true;
 }
开发者ID:shankarbala33,项目名称:snippets,代码行数:33,代码来源:General.php

示例2: getDefaultTransformerNamespace

 /**
  * Get the default transformer class for the model.
  *
  * @return string
  */
 protected function getDefaultTransformerNamespace()
 {
     $parts = explode('\\', get_class($this));
     $class = array_last($parts);
     array_forget($parts, array_last(array_keys($parts)));
     return $this->makeTransformer($class, implode('\\', $parts));
 }
开发者ID:erikgall,项目名称:transformer,代码行数:12,代码来源:TransformableModel.php

示例3: peek

 public static function peek()
 {
     if (count(self::$call_stack) === 0) {
         return null;
     }
     return array_last(self::$call_stack);
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:7,代码来源:CallStack.class.php

示例4: peek

 private static function peek()
 {
     if (count(self::$call_stack) === 0) {
         self::push();
     }
     return array_last(self::$call_stack);
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:7,代码来源:Params.class.php

示例5: untranslateURL

 /**
  * Return an url in the default locale
  *
  * @param $url
  * @return string
  */
 function untranslateURL($url)
 {
     $t = app('translator') ?: new TransLaravel();
     // Parse url
     $arrURL = parse_url($url);
     $segments = explode('/', $arrURL['path']);
     if ($t->isLocale($segments[0])) {
         array_shift($segments);
     }
     if (array_last($segments) == '') {
         array_pop($segments);
     }
     $path = implode('/', $segments);
     $newPath = Languages::whereValue($path);
     if ($newPath->count() == 0) {
         $newPath = $path;
     } else {
         $newPath = $newPath->first()->route;
     }
     $returnURL = '';
     $returnURL .= isset($arrURL['scheme']) ? $arrURL['scheme'] . '://' : '';
     $returnURL .= isset($arrURL['host']) ? $arrURL['host'] : '';
     $returnURL .= isset($arrURL['port']) && $arrURL['port'] != 80 ? ':' . $arrURL['port'] : '';
     $returnURL .= '/' . config('app.fallback_language') . '/' . $newPath;
     $returnURL .= isset($arrURL['query']) ? '?' . $arrURL['query'] : '';
     $returnURL .= isset($arrURL['fragment']) ? '#' . $arrURL['fragment'] : '';
     return str_replace('//', '/', $returnURL);
 }
开发者ID:deargonauten,项目名称:translaravel,代码行数:34,代码来源:helpers.php

示例6: authorizeResource

 /**
  * Authorize a resource action based on the incoming request.
  *
  * @param  string  $model
  * @param  string|null  $name
  * @param  array  $options
  * @param  \Illuminate\Http\Request|null  $request
  * @return \Illuminate\Routing\ControllerMiddlewareOptions
  */
 public function authorizeResource($model, $name = null, array $options = [], $request = null)
 {
     $action = with($request ?: request())->route()->getActionName();
     $map = ['index' => 'view', 'create' => 'create', 'store' => 'create', 'show' => 'view', 'edit' => 'update', 'update' => 'update', 'delete' => 'delete'];
     if (!in_array($method = array_last(explode('@', $action)), array_keys($map))) {
         return new ControllerMiddlewareOptions($options);
     }
     $name = $name ?: strtolower(class_basename($model));
     $model = in_array($method, ['index', 'create', 'store']) ? $model : $name;
     return $this->middleware("can:{$map[$method]},{$model}", $options);
 }
开发者ID:chriss-inno,项目名称:misscontest,代码行数:20,代码来源:AuthorizesResources.php

示例7: authorizeResource

 /**
  * Authorize a resource action based on the incoming request.
  *
  * @param  string  $model
  * @param  string|null  $name
  * @param  array  $options
  * @param  \Illuminate\Http\Request|null  $request
  * @return \Illuminate\Routing\ControllerMiddlewareOptions
  */
 public function authorizeResource($model, $name = null, array $options = [], $request = null)
 {
     $method = array_last(explode('@', with($request ?: request())->route()->getActionName()));
     $map = $this->resourceAbilityMap();
     if (!in_array($method, array_keys($map))) {
         return new ControllerMiddlewareOptions($options);
     }
     if (!in_array($method, ['index', 'create', 'store'])) {
         $model = $name ?: strtolower(class_basename($model));
     }
     return $this->middleware("can:{$map[$method]},{$model}", $options);
 }
开发者ID:teckwei1993,项目名称:laravel-in-directadmin,代码行数:21,代码来源:AuthorizesResources.php

示例8: setPath

 public function setPath($path)
 {
     if (!file_exists($path)) {
         throw new ImageManipFileNotFoundException($path);
     }
     $this->path = $path;
     // Try to determine format by file extension
     $format = strtolower(array_last(explode('.', $this->path)));
     if (!in_array($format, self::$FORMATS)) {
         throw new ImageManipUnsupportedFormatException($format);
     }
     $this->format = $format;
 }
开发者ID:erkie,项目名称:cowl,代码行数:13,代码来源:imagemanip.php

示例9: url

 public static function url($url = null)
 {
     $args = is_array($url) ? $url : func_get_args();
     // Fetch params
     if (is_array(array_last($args))) {
         $params = array_pop($args);
         $params = array_map('urlencode', $params);
         $query_string = '?' . fimplode('%__key__;=%__val__;', $params, '&');
     } else {
         $query_string = '';
     }
     return COWL_BASE . implode('/', $args) . $query_string;
 }
开发者ID:erkie,项目名称:cowl,代码行数:13,代码来源:cowl.php

示例10: __construct

 /**
  * PostsController constructor.
  */
 public function __construct()
 {
     $requestUri = request()->route();
     if ($requestUri) {
         $routeUri = $requestUri->getUri();
         $authorize = null;
         $determine = config('vauth')['authorization']['determine'];
         if (strpos($routeUri, $determine) !== false) {
             $authorize = $routeUri;
         } else {
             $action = array_last(explode('@', request()->route()->getActionName()));
             $authorize = $action . $determine . str_singular($routeUri);
         }
         $this->authorize($authorize);
     }
 }
开发者ID:thienkimlove,项目名称:vauth,代码行数:19,代码来源:VauthController.php

示例11: formatAnsi

 /**
  * @param $string
  *
  * @return string
  */
 public function formatAnsi($string)
 {
     $styleStack = [];
     // match all tags like <tag> and </tag>
     $groups = $this->formatParser->parseFormat($string);
     foreach ($groups as $group) {
         $tag = $group[0];
         // <tag> or </tag>
         $styleName = $group[1];
         // tag
         $stylesString = $group[2];
         // stuff like color=red
         // do not process unknown style tags
         if ($styleName !== 'style' && !$this->hasStyle($styleName)) {
             continue;
         }
         // is this a closing tag?
         if (stripos($tag, '/') !== false) {
             // get previous style
             array_pop($styleStack);
             $styleCode = array_last($styleStack);
             if (!$styleCode) {
                 $styleCode = 0;
             }
         } else {
             if ($styleName === 'style') {
                 $style = new ConsoleStyle('style');
             } else {
                 $style = $this->getStyle($styleName);
             }
             if ($style instanceof IConsoleStyle) {
                 // clone style to prevent unwanted
                 // modification on future uses
                 $style = clone $style;
                 $style->parseStyle($stylesString);
                 $styleCode = $style->getStyleCode();
             }
             $styleStack[] = $styleCode;
         }
         // replace first matching tag with the escape sequence;
         $pattern = s('#%s#', preg_quote($tag));
         $escapeSequence = s("[%sm", $styleCode);
         $string = preg_replace($pattern, $escapeSequence, $string, 1);
     }
     $string = $this->formatParser->unescapeTags($string);
     return $string;
 }
开发者ID:weew,项目名称:console-formatter,代码行数:52,代码来源:ConsoleFormatter.php

示例12: process

 private static function process($route)
 {
     $uses = array_get($route->action, 'uses');
     if (!is_null($uses)) {
         //controller
         if (strpos($uses, "@") > -1) {
             list($name, $method) = explode("@", $uses);
             $pieces = explode(DS, $name);
             $className = $pieces[count($pieces) - 1] = ucfirst(array_last($pieces)) . "Controller";
             $path = J_APPPATH . "controllers" . DS . trim(implode(DS, $pieces), DS) . EXT;
             if (Request::isLocal()) {
                 if (!File::exists($path)) {
                     trigger_error("File <b>" . $path . "</b> doesn't exists");
                 }
             }
             require_once $path;
             $class = new $className();
             if (Request::isLocal()) {
                 if (!method_exists($class, $method)) {
                     trigger_error("Method <b>" . $method . "</b> doesn't exists on class <b>" . $className . "</b>");
                 }
             }
             return call_user_func_array(array(&$class, $method), $route->parameters);
         } else {
             $path = J_APPPATH . "views" . DS . $uses . EXT;
             if (Request::isLocal()) {
                 if (!File::exists($path)) {
                     trigger_error("File <b>" . $path . "</b> doesn't exists");
                 }
             }
             require $path;
         }
     }
     $handler = array_get($route->action, "handler");
     //closure function
     /*$handler = array_first($route->action, function($key, $value)
     		{
     			return is_callable($value);
     		});*/
     if (!is_null($handler) && is_callable($handler)) {
         return call_user_func_array($handler, $route->parameters);
     }
 }
开发者ID:jura-php,项目名称:jura,代码行数:43,代码来源:Route.php

示例13: ImpErrorHandler

/**
 * A replacement error handler with improved debugging features
 * - Backtraces including function parameters will be printed using TextMate URLs when running on localhost
 * - Only the IMP_FATAL_ERROR_MESSAGE will be displayed if IMP_DEBUG is not defined and true
 * - Most errors (all if IMP_DEBUG is true, < E_STRICT otherwise) are fatal to avoid continuing in abnormal situations
 * - Errors will always be recorded using error_log()
 * - MySQL's error will be printed if non-empty
 * - E_STRICT errors in system paths will be ignored to avoid PEAR/PHP5 compatibility issues
 */
function ImpErrorHandler($error, $message, $file, $line, $context)
{
    if (!(error_reporting() & $error)) {
        return;
        // Obey the error_report() level and ignore the error
    }
    if (substr($file, 0, 5) == '/usr/' and $error == E_STRICT) {
        // TODO: come up with a more precise way to avoid reporting E_STRICT errors for PEAR classes
        return;
    }
    $ErrorTypes = array(E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice', E_RECOVERABLE_ERROR => 'Catchable Fatal Error');
    $ErrorType = isset($ErrorTypes[$error]) ? $ErrorTypes[$error] : 'Unknown';
    // If IMP_DEBUG is defined we make everything fatal - otherwise we abort for anything else than an E_STRICT:
    $fatal = (defined("IMP_DEBUG") and IMP_DEBUG) ? true : $error != E_STRICT;
    $dbt = debug_backtrace();
    assert($dbt[0]['function'] == __FUNCTION__);
    array_shift($dbt);
    // Remove our own entry from the backtrace
    if (defined('IMP_DEBUG') and IMP_DEBUG) {
        print '<div class="Error">';
        print "<p><b>{$ErrorType}</b> at ";
        generate_debug_source_link($file, $line, $message);
        print "</p>";
        if (function_exists('mysql_errno') and mysql_errno() > 0) {
            print '<p>Last MySQL error #' . mysql_errno() . ': <code>' . mysql_error() . '</code></p>';
        }
        generate_debug_backtrace($dbt);
        phpinfo(INFO_ENVIRONMENT | INFO_VARIABLES);
        print '</div>';
    } elseif (defined('IMP_FATAL_ERROR_MESSAGE')) {
        print "\n\n\n";
        print IMP_FATAL_ERROR_MESSAGE;
        print "\n\n\n";
    }
    error_log(__FUNCTION__ . ": {$ErrorType} in {$file} on line {$line}: " . quotemeta($message) . (!empty($dbt) ? ' (Began at ' . kimplode(array_filter_keys(array_last($dbt), array('file', 'line'))) . ')' : ''));
    if ($fatal) {
        if (!headers_sent()) {
            header("HTTP/1.1 500 {$ErrorType}");
        }
        exit(1);
    }
}
开发者ID:acdha,项目名称:impphp,代码行数:51,代码来源:Utilities.php

示例14: parsePath

 private function parsePath()
 {
     if (empty($this->path) || !strstr($this->path, 'gfx') && !strstr($this->path, 'css') && !strstr($this->path, 'js')) {
         $this->is_file = false;
         return;
     }
     // Check to see if it really exists
     if (file_exists($this->path)) {
         $this->is_file = true;
     } elseif (file_exists(self::$files_dir . $this->path)) {
         $this->path = self::$files_dir . $this->path;
         $this->is_file = true;
     }
     // Get the extension
     $this->type = strtolower(array_last(explode('.', $this->path)));
     // Bad filetype!
     if (in_array($this->type, self::$BAD)) {
         $this->is_file = false;
     }
 }
开发者ID:erkie,项目名称:cowl,代码行数:20,代码来源:staticserver.php

示例15: restful

 public static function restful($uri, $name)
 {
     $methods = array("restIndex#GET#/", "restGet#GET#/(:num)", "restNew#GET#/new", "restCreate#POST#/", "restUpdate#PUT#/(:num)", "restDelete#DELETE#/(:num)");
     $uri = trim($uri, "/");
     $pieces = explode(DS, $name);
     $className = $pieces[count($pieces) - 1] = ucfirst(array_last($pieces)) . "Controller";
     $path = J_APPPATH . "controllers" . DS . trim(implode(DS, $pieces), DS) . EXT;
     if (Request::isLocal()) {
         if (!File::exists($path)) {
             trigger_error("File <b>" . $path . "</b> doesn't exists");
         }
     }
     require $path;
     $instance = new $className();
     foreach ($methods as $method) {
         $method = explode("#", $method);
         if (method_exists($instance, $method[0])) {
             Router::register($method[1], $uri . $method[2], $name . "@" . $method[0]);
         }
     }
 }
开发者ID:jura-php,项目名称:jura,代码行数:21,代码来源:Router.php


注:本文中的array_last函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。