Add a value to a key. If a key of the same name has already been added, the key value will be converted into an array and the new value will be pushed to the end of the array.
string $key Key to add:
mixed $value Value to add to the key:
Collection Returns a reference to the object.
public function add($key, $value) {
if (!array_key_exists($key, $this->data)) {
$this->data[$key] = $value;
}
elseif (is_array($this->data[$key])) {
$this->data[$key][] = $value;
}
else {
$this->data[$key] = array(
$this->data[$key],
$value,
);
}
return $this;
}