public static function slice($string, $start, $end = null)
    {
        if ($end !== null) {
            $end -= $start;
        }

        if (function_exists('mb_substr')) {
            return mb_substr($string, $start, $end, static::getEncoding());
        }

        if (function_exists('iconv_substr')) {
            return iconv_substr($string, $start, $end ?: iconv_strlen($string), static::getEncoding());
        }

        return false;
    }
public static function slice($string, $start, $end = null)
    {
        if ($end !== null) {
            $end -= $start;
        }

        if (function_exists('mb_substr')) {
            return mb_substr($string, $start, $end, static::getEncoding());
        }

        if (function_exists('iconv_substr')) {
            return iconv_substr($string, $start, $end ?: iconv_strlen($string), static::getEncoding());
        }

        return false;
    }
public static function slice ( $ string , $ start , $ end = null ) { if ( $ end !== null ) { $ end -= $ start ; } if ( function_exists ( 'mb_substr' ) ) { return mb_substr ( $ string , $ start , $ end , static :: getEncoding ( ) ) ; } if ( function_exists ( 'iconv_substr' ) ) { return iconv_substr ( $ string , $ start , $ end ? : iconv_strlen ( $ string ) , static :: getEncoding ( ) ) ; } return false ; }
Slices string like python.
@param string $string
@param int $start
@param int|null $end
@return bool|string
Slices string like python .