php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #50304 A suggestion about arrays
Submitted: 2009-11-26 00:57 UTC Modified: 2009-11-26 10:16 UTC
From: pgreviews at gmail dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.3.1 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: pgreviews at gmail dot com
New email:
PHP Version: OS:

 

 [2009-11-26 00:57 UTC] pgreviews at gmail dot com
Description:
------------
Hey,

I have a feature suggestion that would be used with array.
You'd simply set your array variable, use a new function (called, say, arygrb, for arraygrab?) and it would echo a part of the array, where you tell it to start and end, that can go across the commas and such.
Something like:
<?php
$array = array("first,"second","third","fourth","fifth");
echo arygrb($array("first","third")<br />);
?>
Which would echo:
first<br />second<br />third
everything up from 'first' to 'third', replacing the "," with <br />

Of course, you could just echo "$array[0] $array[1] $array[2]" but what if it's user input that's in the array?  What if you don't know what is in the array, and you're searching it?

I think this would be handy.  Hope you think so too :)

-PG

Reproduce code:
---------------
---
From manual page: faq
---
<?php
$array = array("first,"second","third","fourth","fifth");
echo $array;  //Would echo "Array", not good, unless you put $array[1]...
echo arygrb($array("first","third")<br />); //Would echo 'first<br />second<br />third, the <br />s actually being line breaks
?>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-26 10:16 UTC] jani@php.net
FYI: http://php.net/implode

We're not gonna add another function just for this.
 [2009-11-26 10:16 UTC] jani@php.net
And http://php.net/array_slice :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 18:01:29 2024 UTC