| @@ 5781-5800 (lines=20) @@ | ||
| 5778 | * |
|
| 5779 | * @return string <p>Return the sub-string.</p> |
|
| 5780 | */ |
|
| 5781 | public static function substr_ileft(string $haystack, string $needle): string |
|
| 5782 | { |
|
| 5783 | if (!isset($haystack[0])) { |
|
| 5784 | return ''; |
|
| 5785 | } |
|
| 5786 | ||
| 5787 | if (!isset($needle[0])) { |
|
| 5788 | return $haystack; |
|
| 5789 | } |
|
| 5790 | ||
| 5791 | if (self::str_istarts_with($haystack, $needle) === true) { |
|
| 5792 | $haystackTmp = self::substr($haystack, self::strlen($needle)); |
|
| 5793 | if ($haystackTmp === false) { |
|
| 5794 | $haystackTmp = ''; |
|
| 5795 | } |
|
| 5796 | $haystack = (string)$haystackTmp; |
|
| 5797 | } |
|
| 5798 | ||
| 5799 | return $haystack; |
|
| 5800 | } |
|
| 5801 | ||
| 5802 | /** |
|
| 5803 | * Removes an suffix ($needle) from end of the string ($haystack), case insensitive. |
|
| @@ 5810-5829 (lines=20) @@ | ||
| 5807 | * |
|
| 5808 | * @return string <p>Return the sub-string.</p> |
|
| 5809 | */ |
|
| 5810 | public static function substr_iright(string $haystack, string $needle): string |
|
| 5811 | { |
|
| 5812 | if (!isset($haystack[0])) { |
|
| 5813 | return ''; |
|
| 5814 | } |
|
| 5815 | ||
| 5816 | if (!isset($needle[0])) { |
|
| 5817 | return $haystack; |
|
| 5818 | } |
|
| 5819 | ||
| 5820 | if (self::str_iends_with($haystack, $needle) === true) { |
|
| 5821 | $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle)); |
|
| 5822 | if ($haystackTmp === false) { |
|
| 5823 | $haystackTmp = ''; |
|
| 5824 | } |
|
| 5825 | $haystack = (string)$haystackTmp; |
|
| 5826 | } |
|
| 5827 | ||
| 5828 | return $haystack; |
|
| 5829 | } |
|
| 5830 | ||
| 5831 | /** |
|
| 5832 | * Removes an prefix ($needle) from start of the string ($haystack). |
|
| @@ 5839-5858 (lines=20) @@ | ||
| 5836 | * |
|
| 5837 | * @return string <p>Return the sub-string.</p> |
|
| 5838 | */ |
|
| 5839 | public static function substr_left(string $haystack, string $needle): string |
|
| 5840 | { |
|
| 5841 | if (!isset($haystack[0])) { |
|
| 5842 | return ''; |
|
| 5843 | } |
|
| 5844 | ||
| 5845 | if (!isset($needle[0])) { |
|
| 5846 | return $haystack; |
|
| 5847 | } |
|
| 5848 | ||
| 5849 | if (self::str_starts_with($haystack, $needle) === true) { |
|
| 5850 | $haystackTmp = self::substr($haystack, self::strlen($needle)); |
|
| 5851 | if ($haystackTmp === false) { |
|
| 5852 | $haystackTmp = ''; |
|
| 5853 | } |
|
| 5854 | $haystack = (string)$haystackTmp; |
|
| 5855 | } |
|
| 5856 | ||
| 5857 | return $haystack; |
|
| 5858 | } |
|
| 5859 | ||
| 5860 | /** |
|
| 5861 | * Replace text within a portion of a string. |
|
| @@ 5970-5989 (lines=20) @@ | ||
| 5967 | * |
|
| 5968 | * @return string <p>Return the sub-string.</p> |
|
| 5969 | */ |
|
| 5970 | public static function substr_right(string $haystack, string $needle): string |
|
| 5971 | { |
|
| 5972 | if (!isset($haystack[0])) { |
|
| 5973 | return ''; |
|
| 5974 | } |
|
| 5975 | ||
| 5976 | if (!isset($needle[0])) { |
|
| 5977 | return $haystack; |
|
| 5978 | } |
|
| 5979 | ||
| 5980 | if (self::str_ends_with($haystack, $needle) === true) { |
|
| 5981 | $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle)); |
|
| 5982 | if ($haystackTmp === false) { |
|
| 5983 | $haystackTmp = ''; |
|
| 5984 | } |
|
| 5985 | $haystack = (string)$haystackTmp; |
|
| 5986 | } |
|
| 5987 | ||
| 5988 | return $haystack; |
|
| 5989 | } |
|
| 5990 | ||
| 5991 | /** |
|
| 5992 | * Returns a case swapped version of the string. |
|