# [SPAM] Re:  Syntactic improvement to array

- Thread: https://externals.io/message/27803
- Original archive: https://news-web.php.net/php.internals/27803
- Started by Ford on 2007-02-05T11:29:52+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #27803 — Ford — 2007-02-05T11:29:52+00:00

URL: https://externals.io/message/27803#27803

> Lukas Kahwe Smith wrote:
> > […]
> 
> Nested arrays become very unreadable with the current PHP syntax. I
> think killing those 5 chars per array would actually make thing more
> readable. 
> 
> 
> I don't find:
> 
> $a = [1 => ['pears', 'apples'], 2 => ['juice', 'oranges']];
> 
> any less readable than:
> 
> $a = array(1 => array('pears', 'apples'), 2 => array('juice',
> 'oranges')); 
> 
> Quite the opposite actually :)

Me too - I go beyond Edin on this one, as I find the array() version actually quite UNreadable and I have difficulty picking out what the individual arrays are; conversely, the [] version I take in at a glance.

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

---

## #27808 — Brian Moon — 2007-02-05T17:29:25+00:00

URL: https://externals.io/message/27803#27808 · In reply to: #27803

Ford, Mike wrote:
> > […]
> 
> Me too - I go beyond Edin on this one, as I find the array() version actually quite UNreadable and I have difficulty picking out what the individual arrays are; conversely, the [] version I take in at a glance.

That is why you have coding standards.  Our doucment states that this 
should be written as:

$a = array(
	1 => array('pears', 'apples'),
	2 => array('juice', 'oranges')
);

I believe in either syntax, proper formatting of complex data can solve 
the readablity problems.

-- 

Brian Moon
-------------
http://dealnews.com/
It's good to be cheap =)
