From:             sdeonline at gmail dot com
Operating system: Irrelevant
PHP version:      Irrelevant
Package:          Strings related
Bug Type:         Feature/Change Request
Bug description:If second parameter is present, parse_str should return the 
generated array.

Description:
------------
---
>From manual page:
http://www.php.net/function.parse-str#refsect1-function.parse-
str-returnvalues
---

In my humble opinion parse_str should be able to return the array it
generates 
when it's not parsing to global vars. 
This could save lines of code and be more understandable.

This is quite useful if converting a received method variable as a
parameter to 
another method that requires an array parameter. Because you don't need an
extra 
line to just parse the string.

Test script:
---------------
// Initial string
$string = 'foo=bar&fruit=apple';

// This works:
// parse_str($string,$array);
// print_r($array);

// Now this would be better!
print_r(parse_str($string,true));

// Or the easy to the eyes version (but it quite misses the point.
$array = parse_str($string,true);
print_r($array);

Expected result:
----------------
Array 
( 
    [foo] => bar 
    [fruit] => apple 
)
Array 
( 
    [foo] => bar 
    [fruit] => apple 
)

Actual result:
--------------
Fatal error: Only variables can be passed by reference on line 9

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

Reply via email to