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