public function AnalyseCssNumber($string) {
		// most simple checks first
		if (strlen($string) == 0 || ctype_alpha($string{0})) {
			return false;
		}

		$units = & $this->parser->data['csstidy']['units'];
		$return = array(0, '');

		$return[0] = floatval($string);
		if (abs($return[0]) > 0 && abs($return[0]) < 1) {
			if ($return[0] < 0) {
				$return[0] = '-' . ltrim(substr($return[0], 1), '0');
			} else {
				$return[0] = ltrim($return[0], '0');
			}
		}

		// Look for unit and split from value if exists
		foreach ($units as $unit) {
			$expectUnitAt = strlen($string) - strlen($unit);
			if (!($unitInString = stristr($string, $unit))) { // mb_strpos() fails with "false"
				continue;
			}
			$actualPosition = strpos($string, $unitInString);
			if ($expectUnitAt === $actualPosition) {
				$return[1] = $unit;
				$string = substr($string, 0, - strlen($unit));
				break;
			}
		}
		if (!is_numeric($string)) {
			return false;
		}
		return $return;
	}
public function AnalyseCssNumber($string) {
		// most simple checks first
		if (strlen($string) == 0 || ctype_alpha($string{0})) {
			return false;
		}

		$units = & $this->parser->data['csstidy']['units'];
		$return = array(0, '');

		$return[0] = floatval($string);
		if (abs($return[0]) > 0 && abs($return[0]) < 1) {
			if ($return[0] < 0) {
				$return[0] = '-' . ltrim(substr($return[0], 1), '0');
			} else {
				$return[0] = ltrim($return[0], '0');
			}
		}

		// Look for unit and split from value if exists
		foreach ($units as $unit) {
			$expectUnitAt = strlen($string) - strlen($unit);
			if (!($unitInString = stristr($string, $unit))) { // mb_strpos() fails with "false"
				continue;
			}
			$actualPosition = strpos($string, $unitInString);
			if ($expectUnitAt === $actualPosition) {
				$return[1] = $unit;
				$string = substr($string, 0, - strlen($unit));
				break;
			}
		}
		if (!is_numeric($string)) {
			return false;
		}
		return $return;
	}
public function AnalyseCssNumber ( $ string ) { // most simple checks first if ( strlen ( $ string ) == 0 || ctype_alpha ( $ string { 0 } ) ) { return false ; } $ units = & $ this -> parser -> data [ 'csstidy' ] [ 'units' ] ; $ return = array ( 0 , '' ) ; $ return [ 0 ] = floatval ( $ string ) ; if ( abs ( $ return [ 0 ] ) > 0 && abs ( $ return [ 0 ] ) < 1 ) { if ( $ return [ 0 ] < 0 ) { $ return [ 0 ] = '-' . ltrim ( substr ( $ return [ 0 ] , 1 ) , '0' ) ; } else { $ return [ 0 ] = ltrim ( $ return [ 0 ] , '0' ) ; } } // Look for unit and split from value if exists foreach ( $ units as $ unit ) { $ expectUnitAt = strlen ( $ string ) - strlen ( $ unit ) ; if ( ! ( $ unitInString = stristr ( $ string , $ unit ) ) ) { // mb_strpos() fails with "false" continue ; } $ actualPosition = strpos ( $ string , $ unitInString ) ; if ( $ expectUnitAt === $ actualPosition ) { $ return [ 1 ] = $ unit ; $ string = substr ( $ string , 0 , - strlen ( $ unit ) ) ; break ; } } if ( ! is_numeric ( $ string ) ) { return false ; } return $ return ; }
Checks if a given string is a CSS valid number. If it is,
an array containing the value and unit is returned
@param string $string
@return array ('unit' if unit is found or '' if no unit exists, number value) or false if no number
Checks if a given string is a CSS valid number . If it is an array containing the value and unit is returned