Same name in other branches
- 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/
Parameters
string $str:
int $start index:
int|bool $end index (optional):
Return value
string
5 calls to CSSmin::str_slice()
- CSSmin::compress_hex_colors in 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 in 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 in advagg_css_minify/
yui/ CSSMin.inc - Does bulk of the minification
- CSSmin::replace_string in advagg_css_minify/
yui/ CSSMin.inc - CSSmin::run in advagg_css_minify/
yui/ CSSMin.inc - Minify a string of CSS
File
-
advagg_css_minify/
yui/ CSSMin.inc, line 748
Class
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;
}