| @@ 311-320 (lines=10) @@ | ||
| 308 | * | |
| 309 | * @return string | |
| 310 | */ | |
| 311 | public static function replaceFirst($search, $replace, $subject) | |
| 312 |     { | |
| 313 | $position = strpos($subject, $search); | |
| 314 | ||
| 315 |         if ($position !== false) { | |
| 316 | return substr_replace($subject, $replace, $position, strlen($search)); | |
| 317 | } | |
| 318 | ||
| 319 | return $subject; | |
| 320 | } | |
| 321 | ||
| 322 | /** | |
| 323 | * Replace the last occurrence of a given value in the string. | |
| @@ 331-340 (lines=10) @@ | ||
| 328 | * | |
| 329 | * @return string | |
| 330 | */ | |
| 331 | public static function replaceLast($search, $replace, $subject) | |
| 332 |     { | |
| 333 | $position = strrpos($subject, $search); | |
| 334 | ||
| 335 |         if ($position !== false) { | |
| 336 | return substr_replace($subject, $replace, $position, strlen($search)); | |
| 337 | } | |
| 338 | ||
| 339 | return $subject; | |
| 340 | } | |
| 341 | ||
| 342 | /** | |
| 343 | * Convert the given string to upper-case. | |