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


PHP Str::replaceLast方法代码示例

本文整理汇总了PHP中Illuminate\Support\Str::replaceLast方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::replaceLast方法的具体用法?PHP Str::replaceLast怎么用?PHP Str::replaceLast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Str的用法示例。


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

示例1: handle

 public function handle($request, \Closure $next)
 {
     if (substr($request->getRequestUri(), -1) == '/') {
         $baseUrl = $request->getBaseUrl();
         // try to remove slash at the end of current url
         $newUrl = substr($request->getRequestUri(), 0, -1);
         if ($newUrl != $baseUrl) {
             return redirect(Str::replaceLast($baseUrl, '', $newUrl));
         }
     }
     return $next($request);
 }
开发者ID:printempw,项目名称:blessing-skin-server,代码行数:12,代码来源:RedirectIfUrlEndsWithSlash.php

示例2: getAttribute

 public function getAttribute($key)
 {
     if ($this->isUseImageMax()) {
         $attribute = parent::getAttribute($key);
         if (!$attribute) {
             $profiles = config('imagemax.profiles', []);
             foreach ($profiles as $profile => $options) {
                 if (Str::endsWith($key, $last = '_' . str_slug($profile, '_'))) {
                     $image = Str::replaceLast($last, '', $key);
                     if (in_array($image, $this->getImagableAttributes()) && $this->getAttribute($image)) {
                         return ImageMax::make($this->getAttribute($image), $options);
                     }
                 }
             }
         }
         return $attribute;
     }
     return $this->thumbnailerGetAttribute($key);
 }
开发者ID:livecms,项目名称:core,代码行数:19,代码来源:ImagableTrait.php

示例3:

 /**
  * Replace the last occurrence of a given value in the string.
  *
  * @param  string  $search
  * @param  string  $replace
  * @param  string  $subject
  * @return string
  */
 function str_replace_last($search, $replace, $subject)
 {
     return Str::replaceLast($search, $replace, $subject);
 }
开发者ID:mark86092,项目名称:laravel-framework,代码行数:12,代码来源:helpers.php

示例4: function

     */
    Str::macro('lastSegment', function ($string, $delimiter) {
        return Str::segment($string, $delimiter, -1);
    });
}
if (!Str::hasMacro('pop')) {
    /**
     * Pop off the last segment of a string based on a delimiter.
     * Returns the remaining string.
     *
     * @param string $string
     * @param string $delimiter
     * @return string
     */
    Str::macro('pop', function ($string, $delimiter) {
        return Str::replaceLast($delimiter . Str::lastSegment($string, $delimiter), '', $string);
    });
}
if (!Str::hasMacro('tease')) {
    /**
     * Shortens a string in a pretty way. Removes all double spaces and HTML.
     * The string is concatenated with the moreTextIndicator.
     *
     * @param string $string
     * @param int    $length
     * @param string $moreTextIndicator
     * @return string
     */
    Str::macro('tease', function ($string, $length = 200, $moreTextIndicator = '...') {
        $string = preg_replace("/\\s+/", ' ', strip_tags(trim($string)));
        if (strlen($string) <= $length) {
开发者ID:propaganistas,项目名称:laravel-helper-macros,代码行数:31,代码来源:Str.php

示例5: getUri

 /**
  * Determine the URI from the given method name.
  *
  * @param  ReflectionMethod $routable
  * @param  string $path
  *
  * @return string
  */
 public function getUri(ReflectionMethod $routable, $path)
 {
     $uri = $path . '/' . implode('-', array_slice(explode('_', Str::snake($routable->name)), 1)) . '/' . $this->getWildcards($routable);
     $uri = str_replace('//', '/', $uri);
     $uri = rtrim($uri, '/');
     if (Str::endsWith($uri, 'index')) {
         $uri = Str::replaceLast('index', '', $uri);
     }
     return $uri;
 }
开发者ID:themsaid,项目名称:laravel-routes-publisher,代码行数:18,代码来源:RoutesPublisherCommand.php


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