SassList::index PHP Метод

index() публичный Метод

New function index returns the list index of a value within a list. For example: index(1px solid red, solid) returns 2. When the value is not found false is returned.
public index ( $value )
    public function index($value)
    {
        for ($i = 0; $i < count($this->value); $i++) {
            if (trim((string) $value) == trim((string) $this->value[$i])) {
                return new SassNumber($i);
            }
        }
        return new SassBoolean(false);
    }

Usage Example

Пример #1
0
 public static function index($list, $value)
 {
     if (!$list instanceof SassList) {
         $list = new SassList($list->toString());
     }
     return $list->index($value);
 }