Re: substr/array_slice in []

From: Date: Tue, 02 Oct 2007 15:37:20 +0000
Subject: Re: substr/array_slice in []
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-32553@lists.php.net to get a copy of this message
2007/10/2, Alexey Zakhlestin <indeyets@gmail.com>: > > On 10/1/07, Martin Alterisio <malterisio777@gmail.com> wrote: > > Sorry to bother, I have a few questions on this matter. > > How will this impact on the SPL ArrayAccess and related interfaces and > > objects? > > Will there be an interface to this functionality? > > If so, how will ranges be passed through to this interface? > > Will this be consistent with substr() and array_slice() if used with an > > ArrayAccess implementation? > > I guess it can be made to work with current ArrayAccess, but result > will be quite slow. (it will need to query requested elements > one-by-one and recombine those in array) > > But adding another interface can solve the problem. Ranges can be > passed exactly the way they are passed to [] operator > > public function rangeGet($start, $length); > public function rangeSet($start, $length, array $data); > > > -- > Alexey Zakhlestin > http://blog.milkfarmsoft.com/ > In that case rangeSet shouldn't have the third argument type hinted. The supplied data could be an ArrayAccess implementor.

« previous php.internals (#32553) next »