3 ms·
While I would love them to bring the array functions more into line with other OO langauges, the entire language is not structured around that concept, so you w
by harisenbon 15y ago
While I would love them to bring the array functions more into line with other OO langauges, the entire language is not structured around that concept, so you would be in essence writing a whole new language.
Because almost all the modern PHP frameworks use arrays to pass data, the short-array syntax makes viewing multi-dimensional arrays much easier, and thus will hopefully result in less bugs.
Example:
$this->link('My Link', array('names'=> array('a', 'b', 'c'), 'values'=> array('a1', 'a2', 'a3') ) );
becomes:
$this->link('My Link', ['names'=> ['a', 'b', 'c'], 'values'=> ['a1', 'a2', 'a3'] ]);
Just removing the word array makes the code much easier to read, especially when you have deeply nested arrays.
- gdulli 15y ago"so you would be in essence writing a whole new language" After having to use PHP for a while, it's no coincidence that these days I am using a whole new language.