pQuery\DomNode::setAttribute PHP Method

setAttribute() public method

Sets value(s) of attribute(s)
public setAttribute ( string | integer $attr, $val, string $compare = 'total', boolean $case_sensitive = false )
$attr string | integer Negative int to count from end
$compare string Find node using "namespace", "name" or "total"
$case_sensitive boolean Compare with case sensitivity
    function setAttribute($attr, $val, $compare = 'total', $case_sensitive = false)
    {
        if ($val === null) {
            return $this->deleteAttribute($attr, $compare, $case_sensitive);
        }
        $f = $this->findAttribute($attr, $compare, $case_sensitive);
        if (is_array($f) && $f) {
            foreach ($f as $a) {
                $this->attributes[$a[2]] = (string) $val;
            }
        } else {
            $this->attributes[$attr] = (string) $val;
        }
    }
DomNode