配列のキーに一致する所に値を挿入する

@param   array   $root
@param   string  $key
@param   mixed   $val

@return  array
545622
public static function set(array $root, string $key, $val){
        $origin = $root;
        $node   = &$root;

        foreach(explode(".", $key) as $key){
            if(!is_array($key) || !array_key_exists($key, $node)){
                return $origin;
            }

            $node   = &$node[$key];
        }

        $node   = $val;

        return $root;
    }
113511
public function whereIn($key, $val)
    {
        if (!$val) {
            throw new Exception("whereIn方法的第二个参数不得为空", Exception::CODE_PARAM_VALUE_ERROR);
        }
        return $this->_where("whereIn", $key, $val);
    }
428364
private function getPathsData($data, string $root): ?array
    {
        if ($data === null || !\is_array($data) || \count($data) === 0) {
            return null;
        }

        return $this->existingPaths($data, $root);
    }
613157
protected function makePage($key, $val)
    {
        // Check if it's a divider
        if ($val === '-') {
            return (object) ['divider' => true];
        }

        // Create a new page
        $page = ['url' => $val, 'divider' => false];
        $page = array_merge($page, $this->makeIcon($key));

        // Check if this item is the currently selected one
        $page['active'] = false;
        if (strpos(URL::current(), parse_url($page['url'], PHP_URL_PATH))) {
            $page['active'] = true;
        }

        // Return the new page
        return (object) $page;
    }
49969
public function arrayKeyValueFunc($key, $val, $current_array = null)
    {
        if (empty($current_array)) {
            return array($key => $val);
        }

        $current_array[$key] = $val;

        return $current_array;
    }
962892
public function setAttribute($key, $val)
    {
        try {
            return $this->_stmt->setAttribute($key, $val);
        } catch (PDOException $e) {
            // require_once 'Zend/Db/Statement/Exception.php';
            throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
        }
    }
1320923
public function setValue($key, $val)
    {
        file_put_contents(
            $this->file,
            sprintf("\$values[%s] = %s;\n", var_export($key, true), var_export($val, true)),
            FILE_APPEND
        );
    }
433441
public function setAndSave($key, $val = null)
    {
        $this->set($key, $val);
        $this->save();

        return $this;
    }
760800
public function create($root, $attrs, $content = null)
    {
        $this->_buffer .= '<'.$root;
        
        if (!is_array($attrs)) {
            $content = $attrs;
            $attrs = [];
        }
        
        if ($attrs) {
            $attrs_str = [];
            foreach ($attrs as $name => $val)
                $attrs_str[] = $name . '="'.htmlspecialchars($val).'"';
            $this->_buffer .= ' ' . implode(' ', $attrs_str);
        }
        
        if (!$content) {
            $this->_buffer .= ' />';
        } else {
            $this->_buffer .= ">";
            
            if (is_string($content))
                $this->_buffer .= $content;
            elseif ($content instanceof \Closure)
                $this->_buffer .= $content();
            else
                throw new Exception\InvalidArgumentException(
                    sprintf('Expecting Closure or string as third argument, %s passed.', gettype($content))
                );
            
            $this->_buffer .= '</'.$root.'>';
        }
    }
806787
public static function cascadeSet(&$source, $key, $val, $returnOnlyLastGeneratedKey = true)
    {
        if (!is_string($key)) {
            return false;
        }

        $stack = array();

        $key = static::cascadeExplode($key);

        $element = &$source;
        while (($d = array_shift($key)) !== null) {
            if (count($key)) {
                if (strlen($d)) {
                    if (!(isset($element[$d]) && is_array($element[$d]))) {
                        $element[$d] = array();
                    }
                    $element = &$element[$d];
                }
                else {
                    $element[] = array();
                    $generatedKey = count($element)-1;
                    $stack[] = $generatedKey;
                    $element = &$element[$generatedKey];
                }
            } else {
                if (strlen($d)) {
                    $element[$d] = $val;
                }
                else {
                    $generatedKey = count($element);
                    $stack[] = $generatedKey;
                    $element[] = $val;
                }

                if ($returnOnlyLastGeneratedKey) {

                    return array_pop($stack);
                }

                return $stack;
            }
        }

        if ($returnOnlyLastGeneratedKey) {

            return array_pop($stack);
        }

        return $stack;
    }
268968
public function set($key,$val)
    {
        if (array_key_exists($key, $this->extras)) {
            $this->extras[$key] = $val;

            return $val;
        }

        return parent::set($key, $val);
    }
1144920
public function setDefaultData($key, $val = null)
    {
        if(is_array($key))
        {
            foreach($key as $k=>$v)
            {
                $this->setDefaultData($k, $v);
            }
        }
        else
        {
            $this->defaultData[$key] = $val;
        }

        return $this;
    }
928341
public function virtual($key, $val) {
		$this->vFields[$key]=$val;
		if (!empty($this->whitelist)) {
			$this->whitelist[] = $key;
			$this->whitelist = array_unique($this->whitelist);
		}
	}
999203
public function getKeyValueMap($root = '/', $recursive = true, $key = null)
    {
        $this->listSubdirs($root, $recursive);
        if (isset($this->values[ $key ])) {
            return $this->values[ $key ];
        }

        return $this->values;
    }
880997
public function add($key, $val)
    {
      if (is_array($key))
        foreach($key as $k)
          $this->data[$k] = $val;
      else
        if (is_array($val))
          $this->data[$key] = $val;
      else
        $this->data[$key] = (string) $val;
    }
1275149
static function arraySet(&$var, $key, $val) {
        $toks = explode('.', $key);
        
        for ($i = 0; $i < count($toks); $i++) {
            $var = &$var[$toks[$i]];
        }
        
        $var = $val;
    }
174861
public function where($key, $val=[], $escape=NULL): QueryBuilderInterface
	{
		return $this->_whereString($key, $val);
	}