| @@ 6535-6558 (lines=24) @@ | ||
| 6532 | * |
|
| 6533 | * @return string <p>Return the sub-string.</p> |
|
| 6534 | */ |
|
| 6535 | public static function substr_ileft($haystack, $needle) |
|
| 6536 | { |
|
| 6537 | // init |
|
| 6538 | $haystack = (string)$haystack; |
|
| 6539 | $needle = (string)$needle; |
|
| 6540 | ||
| 6541 | if (!isset($haystack[0])) { |
|
| 6542 | return ''; |
|
| 6543 | } |
|
| 6544 | ||
| 6545 | if (!isset($needle[0])) { |
|
| 6546 | return $haystack; |
|
| 6547 | } |
|
| 6548 | ||
| 6549 | if (self::str_istarts_with($haystack, $needle) === true) { |
|
| 6550 | $haystackTmp = self::substr($haystack, self::strlen($needle)); |
|
| 6551 | if ($haystackTmp === false) { |
|
| 6552 | $haystackTmp = ''; |
|
| 6553 | } |
|
| 6554 | $haystack = (string)$haystackTmp; |
|
| 6555 | } |
|
| 6556 | ||
| 6557 | return $haystack; |
|
| 6558 | } |
|
| 6559 | ||
| 6560 | /** |
|
| 6561 | * Removes an suffix ($needle) from end of the string ($haystack), case insensitive. |
|
| @@ 6568-6591 (lines=24) @@ | ||
| 6565 | * |
|
| 6566 | * @return string <p>Return the sub-string.</p> |
|
| 6567 | */ |
|
| 6568 | public static function substr_iright($haystack, $needle) |
|
| 6569 | { |
|
| 6570 | // init |
|
| 6571 | $haystack = (string)$haystack; |
|
| 6572 | $needle = (string)$needle; |
|
| 6573 | ||
| 6574 | if (!isset($haystack[0])) { |
|
| 6575 | return ''; |
|
| 6576 | } |
|
| 6577 | ||
| 6578 | if (!isset($needle[0])) { |
|
| 6579 | return $haystack; |
|
| 6580 | } |
|
| 6581 | ||
| 6582 | if (self::str_iends_with($haystack, $needle) === true) { |
|
| 6583 | $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle)); |
|
| 6584 | if ($haystackTmp === false) { |
|
| 6585 | $haystackTmp = ''; |
|
| 6586 | } |
|
| 6587 | $haystack = (string)$haystackTmp; |
|
| 6588 | } |
|
| 6589 | ||
| 6590 | return $haystack; |
|
| 6591 | } |
|
| 6592 | ||
| 6593 | /** |
|
| 6594 | * Removes an prefix ($needle) from start of the string ($haystack). |
|
| @@ 6601-6624 (lines=24) @@ | ||
| 6598 | * |
|
| 6599 | * @return string <p>Return the sub-string.</p> |
|
| 6600 | */ |
|
| 6601 | public static function substr_left($haystack, $needle) |
|
| 6602 | { |
|
| 6603 | // init |
|
| 6604 | $haystack = (string)$haystack; |
|
| 6605 | $needle = (string)$needle; |
|
| 6606 | ||
| 6607 | if (!isset($haystack[0])) { |
|
| 6608 | return ''; |
|
| 6609 | } |
|
| 6610 | ||
| 6611 | if (!isset($needle[0])) { |
|
| 6612 | return $haystack; |
|
| 6613 | } |
|
| 6614 | ||
| 6615 | if (self::str_starts_with($haystack, $needle) === true) { |
|
| 6616 | $haystackTmp = self::substr($haystack, self::strlen($needle)); |
|
| 6617 | if ($haystackTmp === false) { |
|
| 6618 | $haystackTmp = ''; |
|
| 6619 | } |
|
| 6620 | $haystack = (string)$haystackTmp; |
|
| 6621 | } |
|
| 6622 | ||
| 6623 | return $haystack; |
|
| 6624 | } |
|
| 6625 | ||
| 6626 | /** |
|
| 6627 | * Replace text within a portion of a string. |
|
| @@ 6731-6753 (lines=23) @@ | ||
| 6728 | * |
|
| 6729 | * @return string <p>Return the sub-string.</p> |
|
| 6730 | */ |
|
| 6731 | public static function substr_right($haystack, $needle) |
|
| 6732 | { |
|
| 6733 | $haystack = (string)$haystack; |
|
| 6734 | $needle = (string)$needle; |
|
| 6735 | ||
| 6736 | if (!isset($haystack[0])) { |
|
| 6737 | return ''; |
|
| 6738 | } |
|
| 6739 | ||
| 6740 | if (!isset($needle[0])) { |
|
| 6741 | return $haystack; |
|
| 6742 | } |
|
| 6743 | ||
| 6744 | if (self::str_ends_with($haystack, $needle) === true) { |
|
| 6745 | $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle)); |
|
| 6746 | if ($haystackTmp === false) { |
|
| 6747 | $haystackTmp = ''; |
|
| 6748 | } |
|
| 6749 | $haystack = (string)$haystackTmp; |
|
| 6750 | } |
|
| 6751 | ||
| 6752 | return $haystack; |
|
| 6753 | } |
|
| 6754 | ||
| 6755 | /** |
|
| 6756 | * Returns a case swapped version of the string. |
|