MongoHybrid\Client::lset PHP Method

lset() public method

Set the value of an element in a list by its index
public lset ( string $collection, string $key, integer $index, mixed $value ) : boolean
$collection string
$key string
$index integer
$value mixed
return boolean
    public function lset($collection, $key, $index, $value)
    {
        $list = $this->getKey($collection, $key, []);
        if ($index < 0) {
            $index = count($list) - abs($index);
        }
        if (isset($list[$index])) {
            $list[$index] = $value;
            $this->setKey($collection, $key, $list);
            return true;
        }
        return false;
    }