public function removeClass(DOMElement &$element, $class)
    {
        // Get current class
        $currentClass = trim($this->attr($element, 'class'));

        // Check if class doesn't exists
        $classes = explode(' ', $currentClass);
        $classKey = array_search($class, $classes);
        if ($classKey === false) {
            return $element;
        }

        // Remove class and set new class attribute
        unset($classes[$classKey]);
        $newClass = implode(' ', $classes);

        // Update attribute
        $this->attr($element, 'class', empty($newClass) ? null : $newClass);

        // Return the HTML element
        return $element;
    }
public function removeClass(DOMElement &$element, $class)
    {
        // Get current class
        $currentClass = trim($this->attr($element, 'class'));

        // Check if class doesn't exists
        $classes = explode(' ', $currentClass);
        $classKey = array_search($class, $classes);
        if ($classKey === false) {
            return $element;
        }

        // Remove class and set new class attribute
        unset($classes[$classKey]);
        $newClass = implode(' ', $classes);

        // Update attribute
        $this->attr($element, 'class', empty($newClass) ? null : $newClass);

        // Return the HTML element
        return $element;
    }
public function removeClass ( DOMElement & $ element , $ class ) { // Get current class $ currentClass = trim ( $ this -> attr ( $ element , 'class' ) ) ; // Check if class doesn't exists $ classes = explode ( ' ' , $ currentClass ) ; $ classKey = array_search ( $ class , $ classes ) ; if ( $ classKey === false ) { return $ element ; } // Remove class and set new class attribute unset ( $ classes [ $ classKey ] ) ; $ newClass = implode ( ' ' , $ classes ) ; // Update attribute $ this -> attr ( $ element , 'class' , empty ( $ newClass ) ? null : $ newClass ) ; // Return the HTML element return $ element ; }
Removes a class from the DOMElement.

@param DOMElement $element The DOMElement to handle.
@param string     $class   The class name.

@return DOMElement
@throws Exception
Removes a class from the DOMElement .