Same name in other branches
  1. 8.x-3.x advagg_css_minify/yui/CSSMin.inc \CSSmin::str_slice()

PHP port of Javascript's "slice" function for strings only Author: Tubal Martin http://blog.margenn.com Tests: http://margenn.com/tubal/str_slice/

Paramètres

string $str:

int $start index:

int|bool $end index (optional):

Return value

string

5 calls to CSSmin::str_slice()
CSSmin::compress_hex_colors dans advagg_css_minify/yui/CSSMin.inc
Utility method to compress hex color values of the form #AABBCC to #ABC or short color name.
CSSmin::extract_data_urls dans advagg_css_minify/yui/CSSMin.inc
Utility method to replace all data urls with tokens before we start compressing, to avoid performance issues running some of the subsequent regexes against large strings chunks.
CSSmin::minify dans advagg_css_minify/yui/CSSMin.inc
Does bulk of the minification
CSSmin::replace_string dans advagg_css_minify/yui/CSSMin.inc
CSSmin::run dans advagg_css_minify/yui/CSSMin.inc
Minify a string of CSS

Fichier

advagg_css_minify/yui/CSSMin.inc, line 748

Classe

CSSmin

Code

private function str_slice($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;
}