| @@ 17-25 (lines=9) @@ | ||
| 14 | * |
|
| 15 | * @return bool|string |
|
| 16 | */ |
|
| 17 | public static function pop(string &$str, string $encoding = null) |
|
| 18 | { |
|
| 19 | $encoding = $encoding ?: mb_internal_encoding(); |
|
| 20 | ||
| 21 | $last = mb_substr($str, -1, null, $encoding); |
|
| 22 | $str = mb_substr($str, 0, -1, $encoding); |
|
| 23 | ||
| 24 | return $last; |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * Shift a character off the beginning of string |
|
| @@ 35-43 (lines=9) @@ | ||
| 32 | * |
|
| 33 | * @return bool|string |
|
| 34 | */ |
|
| 35 | public static function shift(string &$str, string $encoding = null) |
|
| 36 | { |
|
| 37 | $encoding = $encoding ?: mb_internal_encoding(); |
|
| 38 | ||
| 39 | $first = mb_substr($str, 0, 1, $encoding); |
|
| 40 | $str = mb_substr($str, 1, null, $encoding); |
|
| 41 | ||
| 42 | return $first; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * Cut substring from the beginning of string |
|