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