Assalamu'alaikum wr. wb.

Derick Rethans wrote:
 
> Hello,
 
> I would say -1 on this, this is not readable and IMHO just a hack:
 
> $array = [['9', 34],[7],[1,'string']];

And this is a lot better?
  $array = array(array('9', 34),array(7),array(1, 'string'));

IMHO the array() only making line noise instead revealing the intent.

Consider more complex use of array.

$param = array(table => 'emp'
            , fields => array(
                id => array(datatype => INT, pk => true)
                , name => array(datatype => STRING, unique => true
                    , not_null => true)
                , dept_id => array(datatype => INT, not_null => true
                    , fk => array(table => 'dept', field => 'dept_id')
                )
            )   
         ); 

with
            
$param = [table => 'emp'
            , fields => [
                id => [datatype => INT, pk => true]
                , name => [datatype => STRING, unique => true, not_null
=> true]
                , dept_id => [datatype => INT, not_null => true
                    , fk => [table => 'dept', field => 'dept_id']
                ]   
            ]   
        ]   

And the use of array as named parameter

db(array(name => 'comic', user => 'web', password => 's3cret!'));

with

db([name => 'comic', user => 'web', password => 's3cret!']);

and if that's not enough consider that in other scripting languange
array constant is expressed in less character than PHP.

For example:
  Perl: $list = (1, 2 ,3, 'four', 'five', (6.1, 6.2, 6.3));
Python: list = [1, 2, 3, 'four', 'five', [6.1, 6.2, 6.3]]
  Ruby: list = [1, 2, 3, 'four', 'five', [6.1, 6.2, 6.3]]
   Tcl: set list {1 2 3 four five {6.1 6.2 6.3}}

   PHP: $list = array(1, 2, 3, 'four', 'five', array(6.1, 6.2, 6.3));

 
> regrads,
> Derick

> Derick Rethans

Wassallam,


-- Zakaria                         
   Work: [EMAIL PROTECTED], http://asia-karsa.com
Private: [EMAIL PROTECTED]     Yahoo!: z4k4ri4
   http://pemula.linux.or.id

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to