#50304 [NEW]: A suggestion about arrays

2009-11-25 Thread pgreviews at gmail dot com
From: pgreviews at gmail dot com
Operating system: Linux
PHP version:  5.3.1
PHP Bug Type: Feature/Change Request
Bug description:  A suggestion about arrays

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:
);
?>
Which would echo:
firstsecondthird
everything up from 'first' to 'third', replacing the "," with 

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
---
); //Would echo 'firstsecondthird, the s actually being line breaks
?>


-- 
Edit bug report at http://bugs.php.net/?id=50304&edit=1
-- 
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=50304&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=50304&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=50304&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=50304&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=50304&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=50304&r=alreadyfixed
Need backtrace:  
http://bugs.php.net/fix.php?id=50304&r=needtrace
Need Reproduce Script:   
http://bugs.php.net/fix.php?id=50304&r=needscript
Try newer version:   
http://bugs.php.net/fix.php?id=50304&r=oldversion
Not developer issue: 
http://bugs.php.net/fix.php?id=50304&r=support
Expected behavior:   
http://bugs.php.net/fix.php?id=50304&r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=50304&r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=50304&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=50304&r=globals
PHP 4 support discontinued:  http://bugs.php.net/fix.php?id=50304&r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=50304&r=dst
IIS Stability:   
http://bugs.php.net/fix.php?id=50304&r=isapi
Install GNU Sed: 
http://bugs.php.net/fix.php?id=50304&r=gnused
Floating point limitations:  
http://bugs.php.net/fix.php?id=50304&r=float
No Zend Extensions:  
http://bugs.php.net/fix.php?id=50304&r=nozend
MySQL Configuration Error:   
http://bugs.php.net/fix.php?id=50304&r=mysqlcfg



[PHP-BUG] Req #55389 [NEW]: Feature suggestion for array_search

2011-08-09 Thread pgreviews at gmail dot com
From: 
Operating system: Ubuntu Linux
PHP version:  Irrelevant
Package:  Arrays related
Bug Type: Feature/Change Request
Bug description:Feature suggestion for array_search

Description:

---
>From manual page: http://www.php.net/function.array-search
---

Hello!

I am trying to create a simple function to check whether to show an image
or display the contents of a file.  If the input is an image-type, show it
as an image, and if it's text-type, show it's source code.

I figured the best way to do this was to grab the file extension, and work
from there.  Here's my code:

--
$filetypes=array(
"text" => array("txt","php","xml","html","htm","cgi"),
"image" => array("png","jpg","jpeg","svg","bmp")
);
$type=array_search("png",$filetypes);
echo $type;
--

Basically, I want it to return 'image', in this case, because the supplied
input 'png' is in the 'image' key.  However, array_search doesn't check
arrays within arrays.

If array_search could possibly be updated to provide a search within
multidimensional arrays, that would be fantastic!

Thanks!

-Scott (pgrevi...@gmail.com)

Test script:
---
//Filetypes array, one key for text and one key for image extensions
(shortened)
$filetypes=array(
"text" => array("txt","php","xml","html","htm","cgi"),
"image" => array("png","jpg","jpeg","svg","bmp")
);
//Look through the array for 'png', and return it's respective key.  Then
echo it.
echo $type=array_search("png",$filetypes);

Expected result:

I expect it to return 'image'.

Actual result:
--
(null, no output)

-- 
Edit bug report at https://bugs.php.net/bug.php?id=55389&edit=1
-- 
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=55389&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=55389&r=trysnapshot53
Try a snapshot (trunk):  
https://bugs.php.net/fix.php?id=55389&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=55389&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=55389&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=55389&r=alreadyfixed
Need backtrace:  
https://bugs.php.net/fix.php?id=55389&r=needtrace
Need Reproduce Script:   
https://bugs.php.net/fix.php?id=55389&r=needscript
Try newer version:   
https://bugs.php.net/fix.php?id=55389&r=oldversion
Not developer issue: 
https://bugs.php.net/fix.php?id=55389&r=support
Expected behavior:   
https://bugs.php.net/fix.php?id=55389&r=notwrong
Not enough info: 
https://bugs.php.net/fix.php?id=55389&r=notenoughinfo
Submitted twice: 
https://bugs.php.net/fix.php?id=55389&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=55389&r=globals
PHP 4 support discontinued:  
https://bugs.php.net/fix.php?id=55389&r=php4
Daylight Savings:https://bugs.php.net/fix.php?id=55389&r=dst
IIS Stability:   
https://bugs.php.net/fix.php?id=55389&r=isapi
Install GNU Sed: 
https://bugs.php.net/fix.php?id=55389&r=gnused
Floating point limitations:  
https://bugs.php.net/fix.php?id=55389&r=float
No Zend Extensions:  
https://bugs.php.net/fix.php?id=55389&r=nozend
MySQL Configuration Error:   
https://bugs.php.net/fix.php?id=55389&r=mysqlcfg