| @@ 6504-6527 (lines=24) @@ | ||
| 6501 | * |
|
| 6502 | * @return string <p>Return the sub-string.</p> |
|
| 6503 | */ |
|
| 6504 | public static function substr_ileft($haystack, $needle) |
|
| 6505 | { |
|
| 6506 | // init |
|
| 6507 | $haystack = (string)$haystack; |
|
| 6508 | $needle = (string)$needle; |
|
| 6509 | ||
| 6510 | if (!isset($haystack[0])) { |
|
| 6511 | return ''; |
|
| 6512 | } |
|
| 6513 | ||
| 6514 | if (!isset($needle[0])) { |
|
| 6515 | return $haystack; |
|
| 6516 | } |
|
| 6517 | ||
| 6518 | if (self::str_istarts_with($haystack, $needle) === true) { |
|
| 6519 | $haystackTmp = self::substr($haystack, self::strlen($needle)); |
|
| 6520 | if ($haystackTmp === false) { |
|
| 6521 | $haystackTmp = ''; |
|
| 6522 | } |
|
| 6523 | $haystack = (string)$haystackTmp; |
|
| 6524 | } |
|
| 6525 | ||
| 6526 | return $haystack; |
|
| 6527 | } |
|
| 6528 | ||
| 6529 | /** |
|
| 6530 | * Removes an suffix ($needle) from end of the string ($haystack), case insensitive. |
|
| @@ 6537-6560 (lines=24) @@ | ||
| 6534 | * |
|
| 6535 | * @return string <p>Return the sub-string.</p> |
|
| 6536 | */ |
|
| 6537 | public static function substr_iright($haystack, $needle) |
|
| 6538 | { |
|
| 6539 | // init |
|
| 6540 | $haystack = (string)$haystack; |
|
| 6541 | $needle = (string)$needle; |
|
| 6542 | ||
| 6543 | if (!isset($haystack[0])) { |
|
| 6544 | return ''; |
|
| 6545 | } |
|
| 6546 | ||
| 6547 | if (!isset($needle[0])) { |
|
| 6548 | return $haystack; |
|
| 6549 | } |
|
| 6550 | ||
| 6551 | if (self::str_iends_with($haystack, $needle) === true) { |
|
| 6552 | $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle)); |
|
| 6553 | if ($haystackTmp === false) { |
|
| 6554 | $haystackTmp = ''; |
|
| 6555 | } |
|
| 6556 | $haystack = (string)$haystackTmp; |
|
| 6557 | } |
|
| 6558 | ||
| 6559 | return $haystack; |
|
| 6560 | } |
|
| 6561 | ||
| 6562 | /** |
|
| 6563 | * Removes an prefix ($needle) from start of the string ($haystack). |
|
| @@ 6570-6593 (lines=24) @@ | ||
| 6567 | * |
|
| 6568 | * @return string <p>Return the sub-string.</p> |
|
| 6569 | */ |
|
| 6570 | public static function substr_left($haystack, $needle) |
|
| 6571 | { |
|
| 6572 | // init |
|
| 6573 | $haystack = (string)$haystack; |
|
| 6574 | $needle = (string)$needle; |
|
| 6575 | ||
| 6576 | if (!isset($haystack[0])) { |
|
| 6577 | return ''; |
|
| 6578 | } |
|
| 6579 | ||
| 6580 | if (!isset($needle[0])) { |
|
| 6581 | return $haystack; |
|
| 6582 | } |
|
| 6583 | ||
| 6584 | if (self::str_starts_with($haystack, $needle) === true) { |
|
| 6585 | $haystackTmp = self::substr($haystack, self::strlen($needle)); |
|
| 6586 | if ($haystackTmp === false) { |
|
| 6587 | $haystackTmp = ''; |
|
| 6588 | } |
|
| 6589 | $haystack = (string)$haystackTmp; |
|
| 6590 | } |
|
| 6591 | ||
| 6592 | return $haystack; |
|
| 6593 | } |
|
| 6594 | ||
| 6595 | /** |
|
| 6596 | * Replace text within a portion of a string. |
|
| @@ 6700-6722 (lines=23) @@ | ||
| 6697 | * |
|
| 6698 | * @return string <p>Return the sub-string.</p> |
|
| 6699 | */ |
|
| 6700 | public static function substr_right($haystack, $needle) |
|
| 6701 | { |
|
| 6702 | $haystack = (string)$haystack; |
|
| 6703 | $needle = (string)$needle; |
|
| 6704 | ||
| 6705 | if (!isset($haystack[0])) { |
|
| 6706 | return ''; |
|
| 6707 | } |
|
| 6708 | ||
| 6709 | if (!isset($needle[0])) { |
|
| 6710 | return $haystack; |
|
| 6711 | } |
|
| 6712 | ||
| 6713 | if (self::str_ends_with($haystack, $needle) === true) { |
|
| 6714 | $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle)); |
|
| 6715 | if ($haystackTmp === false) { |
|
| 6716 | $haystackTmp = ''; |
|
| 6717 | } |
|
| 6718 | $haystack = (string)$haystackTmp; |
|
| 6719 | } |
|
| 6720 | ||
| 6721 | return $haystack; |
|
| 6722 | } |
|
| 6723 | ||
| 6724 | /** |
|
| 6725 | * Returns a case swapped version of the string. |
|