PHP port of Javascript's "slice" function for strings only Author: Tubal Martin

Paramètres

string $str:

int $start index:

int|bool $end index (optional):

Return value

string

5 calls to CSSmin::strSlice()
CSSmin::minify dans advagg_css_compress/yui/CSSMin.inc
Minifies the given input CSS string
CSSmin::processDataUrls dans advagg_css_compress/yui/CSSMin.inc
Searches & replaces all data urls with tokens before we start compressing, to avoid performance issues running some of the subsequent regexes against large string chunks.
CSSmin::processStrings dans advagg_css_compress/yui/CSSMin.inc
CSSmin::run dans advagg_css_compress/yui/CSSMin.inc
Minifies a string of CSS
CSSmin::shortenHexColors dans advagg_css_compress/yui/CSSMin.inc
Compresses HEX color values of the form #AABBCC to #ABC or short color name.

Fichier

advagg_css_compress/yui/CSSMin.inc, line 1238

Classe

CSSmin

Code

private function strSlice($str, $start = 0, $end = false) {
    if ($end !== false && ($start < 0 || $end <= 0)) {
        $max = strlen($str);
        if ($start < 0) {
            if (($start = $max + $start) < 0) {
                return '';
            }
        }
        if ($end < 0) {
            if (($end = $max + $end) < 0) {
                return '';
            }
        }
        if ($end <= $start) {
            return '';
        }
    }
    $slice = $end === false ? substr($str, $start) : substr($str, $start, $end - $start);
    return $slice === false ? '' : $slice;
}