phpbar.de logo

Mailinglisten-Archive

[php] array_splice-Alternative unter PHP3

[php] array_splice-Alternative unter PHP3

Adi Sieker adi_(at)_living-source.com
Fri, 19 May 2000 14:46:53 GMT


On Fri, 19 May 2000 16:18:41 +0200, Christoph Lauterbach deigned to
write:

>$array = array_splice($array, 10);
>// Array ist nun: array("1","2","3","4","5","6","7","8","9","10");

So ists sauber:
function array_splice($array, $newlength) {
   if( count($array) >= $newlength ) {
      for($i=0; $i <$newlength; $i++) {
         $newarray[] = $array[$i];
      }
      return $newarray;
   }
   else
      return false;
}

und so hasts du's in zwei zeilen:
for($i=0; $i <9; $i++) { $newarray[] = $array[$i]; }
$array = $newarray;

>
>Ein schönes Wochenende wünscht Euch
>der.christoph
>
Danke, dir auch.

Tschau
   Adi

./e2fsck: Illegal triply indirect block found while reading bad blocks
          inode. This doesn't bode well, but we'll try to go on...
~
adi_(at)_living-source.com               tel:+761 / 15 25 8-13
http://www.living-source.com        fax:+761 / 15 25 8-50


php::bar PHP Wiki   -   Listenarchive