| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2018-08-29 22:38 UTC] cmb@php.net
  [2021-08-23 14:50 UTC] cmb@php.net
 
-Package: Arrays related
+Package: Variables related
  [2021-08-23 14:50 UTC] cmb@php.net
  | 
    |||||||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 01:00:02 2025 UTC | 
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, ), )