@@ 279-286 (lines=8) @@ | ||
276 | * @param string $subject |
|
277 | * @return string |
|
278 | */ |
|
279 | public static function replaceFirst($search, $replace, $subject) |
|
280 | { |
|
281 | $position = strpos($subject, $search); |
|
282 | if ($position !== false) { |
|
283 | return substr_replace($subject, $replace, $position, strlen($search)); |
|
284 | } |
|
285 | return $subject; |
|
286 | } |
|
287 | ||
288 | /** |
|
289 | * Replace the last occurrence of a given value in the string. |
|
@@ 296-303 (lines=8) @@ | ||
293 | * @param string $subject |
|
294 | * @return string |
|
295 | */ |
|
296 | public static function replaceLast($search, $replace, $subject) |
|
297 | { |
|
298 | $position = strrpos($subject, $search); |
|
299 | if ($position !== false) { |
|
300 | return substr_replace($subject, $replace, $position, strlen($search)); |
|
301 | } |
|
302 | return $subject; |
|
303 | } |
|
304 | ||
305 | /** |
|
306 | * Convert the given string to title case. |