Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 18, 2021
1 parent 7b0259f commit 20e2470
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/Illuminate/Support/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Support;

use Illuminate\Support\Arr;
use Illuminate\Support\Traits\Macroable;
use League\CommonMark\GithubFlavoredMarkdownConverter;
use Ramsey\Uuid\Codec\TimestampFirstCombCodec;
Expand Down Expand Up @@ -568,17 +569,13 @@ public static function replaceLast($search, $replace, $subject)
*/
public static function remove($search, $subject, $caseSensitive = true)
{
$regexSafeSearches = array_map(function ($search) {
return preg_quote($search);
}, is_array($search) ? $search : [$search]);

$regex = "/".implode("|", $regexSafeSearches)."/";

if (! $caseSensitive) {
$regex .= "i";
foreach (Arr::wrap($search) as $s) {
$subject = $caseSensitive
? str_replace($search, '', $subject)
: str_ireplace($search, '', $subject);
}

return preg_replace($regex, "", $subject);
return $subject;
}

/**
Expand Down

0 comments on commit 20e2470

Please sign in to comment.