PHPRO.ORG

New to PHP 5.4 comes a new method of assigning arrays. In particular, multi-dimensional arrays. Previously to assign a multi-dimensional array this type of code was required


<?php
    $array 
= array( 123, array("fruit"=>"orange""color"=>"blue""type"=>"navel" ) );

    
print_r$array );
?>

New to PHP 5.4 a shortcut has been provided to ease some of the perceived pain of this...


<?php
    
// array with shortcut syntax
    
$array = array[123, ["fruit"=>"orange""color"=>"blue""type"=>"navel"]];

        
print_r$array );
?>