Get key from array by value
https://stackoverflow.com/a/26714857/405758
@return int|null|string
422659
public function doGetKey()
    {
        foreach ($this->data as $key => $value) {
            if ($this->value === $value) {
                return $key;
            }
        }

        return $this->default;
    }
669209
public function arrayAccessByKey($key)
    {
        if (! isset($this->nameLookupTable[$key])) {
            return null;
        }

        if (isset($this->items[$this->nameLookupTable[$key]])) {
            return $this->items[$this->nameLookupTable[$key]];
        }

        return null;
    }
472027
public function keyOf($value)
    {
        foreach ($this->items as $key => $iValue) {
            if ($value === $iValue) {
                return $key;
            }
        }

        return null;
    }
1127819
public function key()
    {
        if (!$this->valid()) {
            return null;
        }

        if (null === $this->keyMapper) {
            return parent::key();
        }

        $map = $this->keyMapper;
        return $map(parent::key(), parent::current());
    }
92867
public function get($key = null)
    {
        if (Arr::key($key, $this->_data)) {
            return $this->_data[$key];
        }

        return $this->_data;
    }
219644
public function getKeyValue()
    {
        if (array_key_exists($this->primary_key, $this->original)) {
            return $this->original[$this->primary_key];
        }

        return null;
    }
665904
public function get($key = null)
    {
        if (null === $key) {
            return $this->get;
        }

        return isset($this->get[$key]) ? $this->get[$key] : null;
    }
376063
public function offsetGet( $key )
    {
        $key = strtolower( $key );
        if ( !array_key_exists( $key, $this->lookup ) )
        {
            return null;
        }
        return $this->map[$this->lookup[$key]];
    }
1192818
protected function first()
    {
        foreach ($this->sortable as $key => $value) {
            if (is_numeric($key)) {
                return $value;
            }

            return $key;
        }

        return null;
    }
1095144
public function getPrimaryKeyValue()
    {
        $primaryKey = $this->getPrimaryKey();
        if (isset($this->$primaryKey)) {
            return $this->$primaryKey;
        } else {
            return null;
        }
    }
797000
protected function _getKey()
    {
        $view = $this->getView();
        $key  = $view->getIdentifier().'-'.$view->getLayout();

        if ($this->getMixer() instanceof KControllerModellable)
        {
            $state = $this->getModel()->getState()->getValues();
            $key  .= ':'.md5(http_build_query($state, '', '&'));
        }

        return $key;
    }
1082166
public function getKeyValue($key)
    {
        foreach ($this->array as $k => $v) {
            if (strtolower($key) == strtolower($k)) {
                return $v;
            }
        }

        return '';
    }
640718
public function get($key)
    {
        if (!is_string($key)) {
            throw new \InvalidArgumentException('Expected string as key');
        }

        if (isset($this->data[$key])) {
            return $this->data[$key];
        } elseif (!$this->isDataLoadedFromDb) {
            $stmt = $this->db->prepare(
                'SELECT * FROM ' . $this->name . ' WHERE ' . $this->keyColumnName
                . ' = :key;'
            );
            $stmt->bindParam(':key', $key, \PDO::PARAM_STR);
            $stmt->execute();

            if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
                $this->data[$row[0]] = $row[1];
                return $this->data[$key];
            }
        }

        return null;
    }
149279
public function getParamValue($key)
    {
        $value = null;
        if (is_array($param = $this->getParam($key))) {
            $value = $param['value'];
        }

        return $value;
    }
1258897
protected function getPrimaryKeyValue()
    {

        // initialize the array for the PK values
        $pk = array();

        // prepare the array with the PK values
        foreach ($this->getPrimaryKeyColumnName() as $columName) {
            $pk[] = $this->getValue($columName);
        }

        // return the array with the PK values
        return $pk;
    }
1302005
public function hmget($key) {

        $set     = $this->getKey($collection, $key, []);
        $fields  = func_get_args();
        $values  = [];

        for ($i=1; $i<count($fields); $i++){
            $field = $fields[$i];
            $values[] = isset($set[$field]) ? $set[$field]:null;
        }

        return $values;
    }
520875
public static function gets($keys = null)
    {
        $noInitModel = static::buildNoInitModel();
        $query = static::find();
        if ($keys == null) {
            $models = $query->all();
        } elseif (is_array($keys)) {
            $array = [];
            foreach ($keys as $key) {
                if (is_string($key) && strlen($key)) {
                    $array[] = $key;
                }
            }
            $models = $query->where([$noInitModel->idAttribute => $array])->all();
        }
        $result = [];
        foreach ($models as $key => $model) {
            $result[$model->key] = $model->value;
        }
        return $result;
    }