Bug #64164 [Opn->Dup]: array_slice function
Edit report at https://bugs.php.net/bug.php?id=64164&edit=1
ID: 64164
Updated by: krakjoe@php.net
Reported by: ajaydixxit at gmail dot com
Summary: array_slice function
-Status: Open
+Status: Duplicate
Type: Bug
Package: Arrays related
Operating System: redhat enterprises 6
PHP Version: 5.3.21
Block user comment: N
Private report: N
New Comment:
Duplicate #64143
Previous Comments:
------------------------------------------------------------------------
[2013-02-06 16:53:58] ajaydixxit at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.array-slice#refsect1-function.array-slice-description
---
I declared an array "my_array" with different offset value.
In my case its offset value is 1. So my_array[0] is not defined. Now when I After that, i used the
predefined function array_slice. In array_slice i entered 1 and 3 as the offset value and required
length value. Now as print the sliced array, it should display:
shiva hanu bhrama
but what i am experiencing is :
vishnu shiva hanu.
It seems like that the array_slice function is not aware of the offset value change in the array.
Test script:
---------------
<?php
$my_array = array( 1 => "vishnu" , "shiva" , "hanu" ,
"bhrama" );
print_r($my_array);
echo $my_array[0]; // this is coming undefined //
$slice = array_slice($my_array,1,3);
print_r($slice);
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64164&edit=1
Thread (2 messages)