ValueLoader::set( $key = null,  $value = null )

Set a value by key

Description

Source

File: bp-integrations/learndash/library/ValueLoader.php

	public function set($key = null, $value = null)
	{
		$target =& $this->value;

        if (is_null($key)) {
        	return $target = $value;
        }

        $keys = explode('.', $key);

        while (count($keys) > 1) {
            $key = array_shift($keys);

            if (! isset($target[$key]) || ! is_array($target[$key])) {
                $target[$key] = array();
            }

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

        $target[array_shift($keys)] = $value;

        return $target;
    }

Changelog

Changelog
Version Description
BuddyBoss 1.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.