當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。