| @@ 6490-6513 (lines=24) @@ | ||
| 6487 | * |
|
| 6488 | * @return string <p>Return the sub-string.</p> |
|
| 6489 | */ |
|
| 6490 | public static function substr_ileft($haystack, $needle) |
|
| 6491 | { |
|
| 6492 | // init |
|
| 6493 | $haystack = (string)$haystack; |
|
| 6494 | $needle = (string)$needle; |
|
| 6495 | ||
| 6496 | if (!isset($haystack[0])) { |
|
| 6497 | return ''; |
|
| 6498 | } |
|
| 6499 | ||
| 6500 | if (!isset($needle[0])) { |
|
| 6501 | return $haystack; |
|
| 6502 | } |
|
| 6503 | ||
| 6504 | if (self::str_istarts_with($haystack, $needle) === true) { |
|
| 6505 | $haystackTmp = self::substr($haystack, self::strlen($needle)); |
|
| 6506 | if ($haystackTmp === false) { |
|
| 6507 | $haystackTmp = ''; |
|
| 6508 | } |
|
| 6509 | $haystack = (string)$haystackTmp; |
|
| 6510 | } |
|
| 6511 | ||
| 6512 | return $haystack; |
|
| 6513 | } |
|
| 6514 | ||
| 6515 | /** |
|
| 6516 | * Removes an suffix ($needle) from end of the string ($haystack), case insensitive. |
|
| @@ 6523-6546 (lines=24) @@ | ||
| 6520 | * |
|
| 6521 | * @return string <p>Return the sub-string.</p> |
|
| 6522 | */ |
|
| 6523 | public static function substr_iright($haystack, $needle) |
|
| 6524 | { |
|
| 6525 | // init |
|
| 6526 | $haystack = (string)$haystack; |
|
| 6527 | $needle = (string)$needle; |
|
| 6528 | ||
| 6529 | if (!isset($haystack[0])) { |
|
| 6530 | return ''; |
|
| 6531 | } |
|
| 6532 | ||
| 6533 | if (!isset($needle[0])) { |
|
| 6534 | return $haystack; |
|
| 6535 | } |
|
| 6536 | ||
| 6537 | if (self::str_iends_with($haystack, $needle) === true) { |
|
| 6538 | $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle)); |
|
| 6539 | if ($haystackTmp === false) { |
|
| 6540 | $haystackTmp = ''; |
|
| 6541 | } |
|
| 6542 | $haystack = (string)$haystackTmp; |
|
| 6543 | } |
|
| 6544 | ||
| 6545 | return $haystack; |
|
| 6546 | } |
|
| 6547 | ||
| 6548 | /** |
|
| 6549 | * Removes an prefix ($needle) from start of the string ($haystack). |
|
| @@ 6556-6579 (lines=24) @@ | ||
| 6553 | * |
|
| 6554 | * @return string <p>Return the sub-string.</p> |
|
| 6555 | */ |
|
| 6556 | public static function substr_left($haystack, $needle) |
|
| 6557 | { |
|
| 6558 | // init |
|
| 6559 | $haystack = (string)$haystack; |
|
| 6560 | $needle = (string)$needle; |
|
| 6561 | ||
| 6562 | if (!isset($haystack[0])) { |
|
| 6563 | return ''; |
|
| 6564 | } |
|
| 6565 | ||
| 6566 | if (!isset($needle[0])) { |
|
| 6567 | return $haystack; |
|
| 6568 | } |
|
| 6569 | ||
| 6570 | if (self::str_starts_with($haystack, $needle) === true) { |
|
| 6571 | $haystackTmp = self::substr($haystack, self::strlen($needle)); |
|
| 6572 | if ($haystackTmp === false) { |
|
| 6573 | $haystackTmp = ''; |
|
| 6574 | } |
|
| 6575 | $haystack = (string)$haystackTmp; |
|
| 6576 | } |
|
| 6577 | ||
| 6578 | return $haystack; |
|
| 6579 | } |
|
| 6580 | ||
| 6581 | /** |
|
| 6582 | * Replace text within a portion of a string. |
|
| @@ 6686-6708 (lines=23) @@ | ||
| 6683 | * |
|
| 6684 | * @return string <p>Return the sub-string.</p> |
|
| 6685 | */ |
|
| 6686 | public static function substr_right($haystack, $needle) |
|
| 6687 | { |
|
| 6688 | $haystack = (string)$haystack; |
|
| 6689 | $needle = (string)$needle; |
|
| 6690 | ||
| 6691 | if (!isset($haystack[0])) { |
|
| 6692 | return ''; |
|
| 6693 | } |
|
| 6694 | ||
| 6695 | if (!isset($needle[0])) { |
|
| 6696 | return $haystack; |
|
| 6697 | } |
|
| 6698 | ||
| 6699 | if (self::str_ends_with($haystack, $needle) === true) { |
|
| 6700 | $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle)); |
|
| 6701 | if ($haystackTmp === false) { |
|
| 6702 | $haystackTmp = ''; |
|
| 6703 | } |
|
| 6704 | $haystack = (string)$haystackTmp; |
|
| 6705 | } |
|
| 6706 | ||
| 6707 | return $haystack; |
|
| 6708 | } |
|
| 6709 | ||
| 6710 | /** |
|
| 6711 | * Returns a case swapped version of the string. |
|