php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64164 array_slice function
Submitted: 2013-02-06 16:53 UTC Modified: 2013-02-06 20:46 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ajaydixxit at gmail dot com Assigned:
Status: Duplicate Package: Arrays related
PHP Version: 5.3.21 OS: redhat enterprises 6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ajaydixxit at gmail dot com
New email:
PHP Version: OS:

 

 [2013-02-06 16:53 UTC] 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);

?>




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-06 20:46 UTC] krakjoe@php.net
-Status: Open +Status: Duplicate
 [2013-02-06 20:46 UTC] krakjoe@php.net
Duplicate #64143
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sat Nov 17 02:01:25 2018 UTC