Short array syntax finally in PHP 5.4
svn.php.net
Short array syntax finally in PHP 5.4
1–10 of 80 posts
Re: Short array syntax finally in PHP 5.4
#2 $a = [1, 2, 3];
and it also will make function calls with named parameters much more readable.Sadly, it will be years before the majority of hosting providers adopt 5.4...
Re: Short array syntax finally in PHP 5.4
#3That's great news, finally we can do $a = [1, 2, 3]; and it also will make function calls with named parameters much more readable. Sadly, it will be years before the majority of hosting providers adopt 5.4...
$a = [1 => [4, 5, 6], 2 => [7, 8, 9], 3 => [10, 11, 12]];
$a = array(1 => array(4, 5, 6), 2 => array(7, 8, 9), 3 => array(10, 11, 12));Re: Short array syntax finally in PHP 5.4
#4That's great news, finally we can do $a = [1, 2, 3]; and it also will make function calls with named parameters much more readable. Sadly, it will be years before the majority of hosting providers adopt 5.4...
Also arrays of arrays have a much more compact syntax: $a = [1 => [4, 5, 6], 2 => [7, 8, 9], 3 => [10, 11, 12]]; $a = array(1 => array(4, 5, 6), 2 => array(7, 8, 9), 3 => array(10, 11, 12));
[[4, 5, 6], [7, 8, 9], [10, 11, 12]]
work?I know PHP has a weird history of rebelling against its C-family-syntax heritage, but requiring the syntax in your example would seem specifically calculated just to make developers' lives harder.
Re: Short array syntax finally in PHP 5.4
#5Earlier quoted context omitted.
Also arrays of arrays have a much more compact syntax: $a = [1 => [4, 5, 6], 2 => [7, 8, 9], 3 => [10, 11, 12]]; $a = array(1 => array(4, 5, 6), 2 => array(7, 8, 9), 3 => array(10, 11, 12));
Uh, why wouldn't [[4, 5, 6], [7, 8, 9], [10, 11, 12]] work? I know PHP has a weird history of rebelling against its C-family-syntax heritage, but requiring the syntax in your example would seem specifically calculated just to make developers' lives harder.
Re: Short array syntax finally in PHP 5.4
#6Earlier quoted context omitted.
Also arrays of arrays have a much more compact syntax: $a = [1 => [4, 5, 6], 2 => [7, 8, 9], 3 => [10, 11, 12]]; $a = array(1 => array(4, 5, 6), 2 => array(7, 8, 9), 3 => array(10, 11, 12));
Uh, why wouldn't [[4, 5, 6], [7, 8, 9], [10, 11, 12]] work? I know PHP has a weird history of rebelling against its C-family-syntax heritage, but requiring the syntax in your example would seem specifically calculated just to make developers' lives harder.
[0 => [4, 5, 6], 1 => [7, 8, 9], 2 => [10, 11, 12]]Re: Short array syntax finally in PHP 5.4
#7 function boo(){
return array(1,2,3)
}
echo boo()[1];Re: Short array syntax finally in PHP 5.4
#8Earlier quoted context omitted.
Also arrays of arrays have a much more compact syntax: $a = [1 => [4, 5, 6], 2 => [7, 8, 9], 3 => [10, 11, 12]]; $a = array(1 => array(4, 5, 6), 2 => array(7, 8, 9), 3 => array(10, 11, 12));
Uh, why wouldn't [[4, 5, 6], [7, 8, 9], [10, 11, 12]] work? I know PHP has a weird history of rebelling against its C-family-syntax heritage, but requiring the syntax in your example would seem specifically calculated just to make developers' lives harder.
$booking = $this->Booking->find('first', array('conditions' => array('Booking.booking_id' => $id), 'contain' => array('Review', 'Desk' => array('fields' =>
array('provider_id', 'category_id'), 'Provider' => array('city', 'name'), 'ProviderCategory' => array('fields' => array('provider_id', 'category_id'), 'DeskCategory' => 'name')))));
It's essentially not readable, but with [] it would work much better, and I still want to give keys to arrays.Re: Short array syntax finally in PHP 5.4
#9Now if only when a function returns an array we needn't a variable... function boo(){ return array(1,2,3) } echo boo()[1];
Re: Short array syntax finally in PHP 5.4
#10Now if only when a function returns an array we needn't a variable... function boo(){ return array(1,2,3) } echo boo()[1];
http://www.php.net/archive/2011.php#id2011-06-28-1
It's in PHP 5.4 alpha as well ;)