| @@ 6673-6696 (lines=24) @@ | ||
| 6670 | * |
|
| 6671 | * @return string <p>Return the sub-string.</p> |
|
| 6672 | */ |
|
| 6673 | public static function substr_ileft($haystack, $needle) |
|
| 6674 | { |
|
| 6675 | // init |
|
| 6676 | $haystack = (string)$haystack; |
|
| 6677 | $needle = (string)$needle; |
|
| 6678 | ||
| 6679 | if (!isset($haystack[0])) { |
|
| 6680 | return ''; |
|
| 6681 | } |
|
| 6682 | ||
| 6683 | if (!isset($needle[0])) { |
|
| 6684 | return $haystack; |
|
| 6685 | } |
|
| 6686 | ||
| 6687 | if (self::str_istarts_with($haystack, $needle) === true) { |
|
| 6688 | $haystackTmp = self::substr($haystack, self::strlen($needle)); |
|
| 6689 | if ($haystackTmp === false) { |
|
| 6690 | $haystackTmp = ''; |
|
| 6691 | } |
|
| 6692 | $haystack = (string)$haystackTmp; |
|
| 6693 | } |
|
| 6694 | ||
| 6695 | return $haystack; |
|
| 6696 | } |
|
| 6697 | ||
| 6698 | /** |
|
| 6699 | * Removes an suffix ($needle) from end of the string ($haystack), case insensitive. |
|
| @@ 6706-6729 (lines=24) @@ | ||
| 6703 | * |
|
| 6704 | * @return string <p>Return the sub-string.</p> |
|
| 6705 | */ |
|
| 6706 | public static function substr_iright($haystack, $needle) |
|
| 6707 | { |
|
| 6708 | // init |
|
| 6709 | $haystack = (string)$haystack; |
|
| 6710 | $needle = (string)$needle; |
|
| 6711 | ||
| 6712 | if (!isset($haystack[0])) { |
|
| 6713 | return ''; |
|
| 6714 | } |
|
| 6715 | ||
| 6716 | if (!isset($needle[0])) { |
|
| 6717 | return $haystack; |
|
| 6718 | } |
|
| 6719 | ||
| 6720 | if (self::str_iends_with($haystack, $needle) === true) { |
|
| 6721 | $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle)); |
|
| 6722 | if ($haystackTmp === false) { |
|
| 6723 | $haystackTmp = ''; |
|
| 6724 | } |
|
| 6725 | $haystack = (string)$haystackTmp; |
|
| 6726 | } |
|
| 6727 | ||
| 6728 | return $haystack; |
|
| 6729 | } |
|
| 6730 | ||
| 6731 | /** |
|
| 6732 | * Removes an prefix ($needle) from start of the string ($haystack). |
|
| @@ 6739-6762 (lines=24) @@ | ||
| 6736 | * |
|
| 6737 | * @return string <p>Return the sub-string.</p> |
|
| 6738 | */ |
|
| 6739 | public static function substr_left($haystack, $needle) |
|
| 6740 | { |
|
| 6741 | // init |
|
| 6742 | $haystack = (string)$haystack; |
|
| 6743 | $needle = (string)$needle; |
|
| 6744 | ||
| 6745 | if (!isset($haystack[0])) { |
|
| 6746 | return ''; |
|
| 6747 | } |
|
| 6748 | ||
| 6749 | if (!isset($needle[0])) { |
|
| 6750 | return $haystack; |
|
| 6751 | } |
|
| 6752 | ||
| 6753 | if (self::str_starts_with($haystack, $needle) === true) { |
|
| 6754 | $haystackTmp = self::substr($haystack, self::strlen($needle)); |
|
| 6755 | if ($haystackTmp === false) { |
|
| 6756 | $haystackTmp = ''; |
|
| 6757 | } |
|
| 6758 | $haystack = (string)$haystackTmp; |
|
| 6759 | } |
|
| 6760 | ||
| 6761 | return $haystack; |
|
| 6762 | } |
|
| 6763 | ||
| 6764 | /** |
|
| 6765 | * Replace text within a portion of a string. |
|
| @@ 6874-6896 (lines=23) @@ | ||
| 6871 | * |
|
| 6872 | * @return string <p>Return the sub-string.</p> |
|
| 6873 | */ |
|
| 6874 | public static function substr_right($haystack, $needle) |
|
| 6875 | { |
|
| 6876 | $haystack = (string)$haystack; |
|
| 6877 | $needle = (string)$needle; |
|
| 6878 | ||
| 6879 | if (!isset($haystack[0])) { |
|
| 6880 | return ''; |
|
| 6881 | } |
|
| 6882 | ||
| 6883 | if (!isset($needle[0])) { |
|
| 6884 | return $haystack; |
|
| 6885 | } |
|
| 6886 | ||
| 6887 | if (self::str_ends_with($haystack, $needle) === true) { |
|
| 6888 | $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle)); |
|
| 6889 | if ($haystackTmp === false) { |
|
| 6890 | $haystackTmp = ''; |
|
| 6891 | } |
|
| 6892 | $haystack = (string)$haystackTmp; |
|
| 6893 | } |
|
| 6894 | ||
| 6895 | return $haystack; |
|
| 6896 | } |
|
| 6897 | ||
| 6898 | /** |
|
| 6899 | * Returns a case swapped version of the string. |
|