public function addObjectAtPosition($value, $intPosition)
    {
        $arrTempCollection = array();
        $intCount = 0;

        if ($intPosition >= $this->count()) {
            // *** Position is greater than the collection count. Just add at the end.
            $this->addObject($value);
        } else {
            foreach ($this->collection as $varObject) {
                if ($intCount == $intPosition) {
                    // *** Insert the new object.
                    array_push($arrTempCollection, $value);
                }

                // *** Insert the existing object.
                array_push($arrTempCollection, $varObject);
                $intCount ++;
            }

            // *** Replace the collection.
            $this->collection = $arrTempCollection;
        }
    }
public function addObjectAtPosition($value, $intPosition)
    {
        $arrTempCollection = array();
        $intCount = 0;

        if ($intPosition >= $this->count()) {
            // *** Position is greater than the collection count. Just add at the end.
            $this->addObject($value);
        } else {
            foreach ($this->collection as $varObject) {
                if ($intCount == $intPosition) {
                    // *** Insert the new object.
                    array_push($arrTempCollection, $value);
                }

                // *** Insert the existing object.
                array_push($arrTempCollection, $varObject);
                $intCount ++;
            }

            // *** Replace the collection.
            $this->collection = $arrTempCollection;
        }
    }
public function addObjectAtPosition ( $ value , $ intPosition ) { $ arrTempCollection = array ( ) ; $ intCount = 0 ; if ( $ intPosition >= $ this -> count ( ) ) { // *** Position is greater than the collection count. Just add at the end. $ this -> addObject ( $ value ) ; } else { foreach ( $ this -> collection as $ varObject ) { if ( $ intCount == $ intPosition ) { // *** Insert the new object. array_push ( $ arrTempCollection , $ value ) ; } // *** Insert the existing object. array_push ( $ arrTempCollection , $ varObject ) ; $ intCount ++ ; } // *** Replace the collection. $ this -> collection = $ arrTempCollection ; } }
Add object to the collection at a specified position

@param object $value The object
@param integer $intPosition The position the object should be placed at.
Add object to the collection at a specified position