public function addWithIndex($index, $element)
    {
        if (!is_null($index)
            && is_scalar($index)
        ) {
            if (!$this->hasIndex($index)) {
                $this->set($index, $element);
            } else {
                // index already exist
                throw new ListException('Element could not be added to list. Index already exist.', E_NOTICE);
            }
        } else {
            // given index name is not valid
            throw new ListException('Element could not be added to list. Index is not valid.', E_NOTICE);
        }
    }
public function addWithIndex($index, $element)
    {
        if (!is_null($index)
            && is_scalar($index)
        ) {
            if (!$this->hasIndex($index)) {
                $this->set($index, $element);
            } else {
                // index already exist
                throw new ListException('Element could not be added to list. Index already exist.', E_NOTICE);
            }
        } else {
            // given index name is not valid
            throw new ListException('Element could not be added to list. Index is not valid.', E_NOTICE);
        }
    }
public function addWithIndex ( $ index , $ element ) { if ( ! is_null ( $ index ) && is_scalar ( $ index ) ) { if ( ! $ this -> hasIndex ( $ index ) ) { $ this -> set ( $ index , $ element ) ; } else { // index already exist throw new ListException ( 'Element could not be added to list. Index already exist.' , E_NOTICE ) ; } } else { // given index name is not valid throw new ListException ( 'Element could not be added to list. Index is not valid.' , E_NOTICE ) ; } }
add a element to a specified position of the list

@param    int        $index          element index
@param    mixed      $element        element
@return   void
@throws   ListException
add a element to a specified position of the list