Skip to content

Commit

Permalink
Update Str.php
Browse files Browse the repository at this point in the history
Improve performance
  • Loading branch information
arshidkv12 authored Jan 18, 2024
1 parent 121cd9d commit 39c2624
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ public static function of($string)
*/
public static function after($subject, $search)
{
return $search === '' ? $subject : array_reverse(explode($search, $subject, 2))[0];
if ($search === '') {
return $subject;
}
$pos = strpos($subject, $search);
return $pos === false ? $subject : substr($subject, $pos + strlen($search));
}

/**
Expand Down

0 comments on commit 39c2624

Please sign in to comment.