php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #23117 Python-style array subsets
Submitted: 2003-04-08 16:08 UTC Modified: 2003-04-29 09:45 UTC
From: eblount at implode dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5CVS-2003-04-08 (dev) OS: All
Private report: No CVE-ID: None
 [2003-04-08 16:08 UTC] eblount at implode dot com
Hi,

I would like to request Python-style array subsets, where the code would resemble the following:

  $subArray = $bigArray[10:20];
  // $subArray contains elements 10 through 20 of $bigArray

It could also be useful in strings:

  $myString = "Hello World";
  $subString = $myString[3:8];
  // $subString equals "lo Wor"

I think this could be done without breaking backwards compatability, and I think it would increase productivity.

Thanks,
Eric Blount
eblount@implode.com

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-29 09:45 UTC] andrey@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

in PHP the Engine is "thin". For the first example use array_slice(). For the second use substr(). It's preferred to use {} instead of [] for strings.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 15 04:01:33 2024 UTC