php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #12879 array_slice - something to be mentioned in the documentation
Submitted: 2001-08-21 11:07 UTC Modified: 2002-02-09 18:14 UTC
From: bodokaelberer at webkind dot de Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.0.4pl1 OS: windows
Private report: No CVE-ID: None
 [2001-08-21 11:07 UTC] bodokaelberer at webkind dot de
hello

i just lost two hours on debugging a problem i wouldn't have encountered, if the documentation
on the array_slice-method would be a bit more precisely.
maybe you can pronouce, that the 'offset', that is passed as the second argument, is not an
offset as it is used as the arrays index, but as the internal pointer of the array.

Example:
=========================
$a	= array();
$a[1]	= 'second';
$a[0]	= 'first';
$b	= array_slice( $a, 1 );
echo join( ', ', $b );
=========================

With something like this, i would exspect an output of:
    second
In fact i get 
    first
because first has been added later. this is logical, as php-arrays are associative
arrays only. But its a quite surprising result if you're familiar with languages as
java, perl or c.

In general, i just want to add, that php is an excellent language for cgi-
programming, but it also has some strange things  (e.g. that a non succuss-
full call to strpos returns false instead of -1 etc.)

bye

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-09 18:14 UTC] torben@php.net
This bug has been fixed in CVS.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 00:01:28 2024 UTC