| @@ 6548-6571 (lines=24) @@ | ||
| 6545 | * |
|
| 6546 | * @return string <p>Return the sub-string.</p> |
|
| 6547 | */ |
|
| 6548 | public static function substr_ileft($haystack, $needle) |
|
| 6549 | { |
|
| 6550 | // init |
|
| 6551 | $haystack = (string)$haystack; |
|
| 6552 | $needle = (string)$needle; |
|
| 6553 | ||
| 6554 | if (!isset($haystack[0])) { |
|
| 6555 | return ''; |
|
| 6556 | } |
|
| 6557 | ||
| 6558 | if (!isset($needle[0])) { |
|
| 6559 | return $haystack; |
|
| 6560 | } |
|
| 6561 | ||
| 6562 | if (self::str_istarts_with($haystack, $needle) === true) { |
|
| 6563 | $haystackTmp = self::substr($haystack, self::strlen($needle)); |
|
| 6564 | if ($haystackTmp === false) { |
|
| 6565 | $haystackTmp = ''; |
|
| 6566 | } |
|
| 6567 | $haystack = (string)$haystackTmp; |
|
| 6568 | } |
|
| 6569 | ||
| 6570 | return $haystack; |
|
| 6571 | } |
|
| 6572 | ||
| 6573 | /** |
|
| 6574 | * Removes an suffix ($needle) from end of the string ($haystack), case insensitive. |
|
| @@ 6581-6604 (lines=24) @@ | ||
| 6578 | * |
|
| 6579 | * @return string <p>Return the sub-string.</p> |
|
| 6580 | */ |
|
| 6581 | public static function substr_iright($haystack, $needle) |
|
| 6582 | { |
|
| 6583 | // init |
|
| 6584 | $haystack = (string)$haystack; |
|
| 6585 | $needle = (string)$needle; |
|
| 6586 | ||
| 6587 | if (!isset($haystack[0])) { |
|
| 6588 | return ''; |
|
| 6589 | } |
|
| 6590 | ||
| 6591 | if (!isset($needle[0])) { |
|
| 6592 | return $haystack; |
|
| 6593 | } |
|
| 6594 | ||
| 6595 | if (self::str_iends_with($haystack, $needle) === true) { |
|
| 6596 | $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle)); |
|
| 6597 | if ($haystackTmp === false) { |
|
| 6598 | $haystackTmp = ''; |
|
| 6599 | } |
|
| 6600 | $haystack = (string)$haystackTmp; |
|
| 6601 | } |
|
| 6602 | ||
| 6603 | return $haystack; |
|
| 6604 | } |
|
| 6605 | ||
| 6606 | /** |
|
| 6607 | * Removes an prefix ($needle) from start of the string ($haystack). |
|
| @@ 6614-6637 (lines=24) @@ | ||
| 6611 | * |
|
| 6612 | * @return string <p>Return the sub-string.</p> |
|
| 6613 | */ |
|
| 6614 | public static function substr_left($haystack, $needle) |
|
| 6615 | { |
|
| 6616 | // init |
|
| 6617 | $haystack = (string)$haystack; |
|
| 6618 | $needle = (string)$needle; |
|
| 6619 | ||
| 6620 | if (!isset($haystack[0])) { |
|
| 6621 | return ''; |
|
| 6622 | } |
|
| 6623 | ||
| 6624 | if (!isset($needle[0])) { |
|
| 6625 | return $haystack; |
|
| 6626 | } |
|
| 6627 | ||
| 6628 | if (self::str_starts_with($haystack, $needle) === true) { |
|
| 6629 | $haystackTmp = self::substr($haystack, self::strlen($needle)); |
|
| 6630 | if ($haystackTmp === false) { |
|
| 6631 | $haystackTmp = ''; |
|
| 6632 | } |
|
| 6633 | $haystack = (string)$haystackTmp; |
|
| 6634 | } |
|
| 6635 | ||
| 6636 | return $haystack; |
|
| 6637 | } |
|
| 6638 | ||
| 6639 | /** |
|
| 6640 | * Replace text within a portion of a string. |
|
| @@ 6744-6766 (lines=23) @@ | ||
| 6741 | * |
|
| 6742 | * @return string <p>Return the sub-string.</p> |
|
| 6743 | */ |
|
| 6744 | public static function substr_right($haystack, $needle) |
|
| 6745 | { |
|
| 6746 | $haystack = (string)$haystack; |
|
| 6747 | $needle = (string)$needle; |
|
| 6748 | ||
| 6749 | if (!isset($haystack[0])) { |
|
| 6750 | return ''; |
|
| 6751 | } |
|
| 6752 | ||
| 6753 | if (!isset($needle[0])) { |
|
| 6754 | return $haystack; |
|
| 6755 | } |
|
| 6756 | ||
| 6757 | if (self::str_ends_with($haystack, $needle) === true) { |
|
| 6758 | $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle)); |
|
| 6759 | if ($haystackTmp === false) { |
|
| 6760 | $haystackTmp = ''; |
|
| 6761 | } |
|
| 6762 | $haystack = (string)$haystackTmp; |
|
| 6763 | } |
|
| 6764 | ||
| 6765 | return $haystack; |
|
| 6766 | } |
|
| 6767 | ||
| 6768 | /** |
|
| 6769 | * Returns a case swapped version of the string. |
|