In other words, what value can be assigned to $key so that the following two lines create exactly the same result:
$arr[] = $value;
$arr[$key] = $value;
The task I need to solve looks like the following: I need to add a new value to an array using either the key if specified, or next available numeric key if key is not specified:
protected $_arr;
...
public function addValue($value, $key = NULL) {
$this->_arr[$key] = $value;
}
Working solutions is like this:
public function addValue($value, $key = NULL) {
if($key === NULL) $this->_arr[] = $value;
else $this->_arr[$key] = $value;
}
I suspect there is no such value for the key as I tried obvious NULL and '' (empty string), and neither brings desired result.