@Dmitry, @soulmerge your answers were good regarding the original question, but there were no requirements in my editing, but they pointed me in the right direction to achieve what I was expecting here is the solution we came here at work: (work for php > = 5.1)
public function unshift($value){ $tmp = $this->getArrayCopy(); $tmp = array($value) + $tmp; $this->exchangeArray($tmp); return $this; }
these examples are not quite the same as the final solution that we need for our specific arrayObject. We use this key in the array values ββas the key for the values ββ(consider using the rowId database as an index for each value in the collection). let this value "key" here, what the actual structure of the array looks like:
array( key1 => array(key=>key1,val1=>val1,val2=>val2...), key2 => array(key=>key2,val1=>val1_2,val2=>val2_2...), ... );
so our solution looks something like this:
public function unshift($value){ $tmp = $this->getArrayCopy(); $tmp = array($value['key'],$value) + $tmp; $this->exchangeArray($tmp); return $this; }
Thanks for your answers, if you find a method that works in php5.0, I am also interested.
malko source share