Req #76811 [NEW]: Add option to var_export so arrays use brackets []
From: mark at seventhcycle dot net
Operating system: Any
PHP version: Next Minor Version
Package: Arrays related
Bug Type: Feature/Change Request
Bug description:Add option to var_export so arrays use brackets []
Description:
------------
Right now, any arrays that are exported via var_export use the longer
array() syntax.
What would be useful here is a third optional argument to var_export:
e.g: var_export($arr, FALSE, TRUE);
Where if the third argument is set to true, the output would use the
shorter, PHP 5.4 syntax.
There are already functions out there (search for var_export54) that do
this sort of thing, however, it would be useful if this were in core
PHP.
The third argument isn't necessary, however, I propose doing it this way
to not break compatibility for existing people who are using
var_export.
Test script:
---------------
$arr = [
'key' => 'value',
'mushroom' => [
'badger' => 1
]
];
var_export($arr, FALSE, TRUE);
Expected result:
----------------
[
'key' => 'value',
'mushroom' => [
'badger' => 1
]
]
Actual result:
--------------
array (
'key' => 'value',
'mushroom' =>
array (
'badger' => 1,
),
)
--
Edit bug report at https://bugs.php.net/bug.php?id=76811&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76811&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76811&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76811&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76811&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76811&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76811&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76811&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76811&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76811&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76811&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76811&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76811&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76811&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76811&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76811&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76811&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76811&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76811&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76811&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76811&r=mysqlcfg
Thread (3 messages)
- mark at seventhcycle dot net