Indentation of array values

Is there a possibility to set indentation of array values, I mean:

 $changes = array(
     'status' => 'PDF print',
     'who' => $user,
     'email' => $email,
     'phone' => $phone,
     'date' => $date
);

into
 $changes = array(
     'status'     => 'PDF print',

    'who'        => $user,
     'email'      => $email,
     'phone'      => $phone,
     'date'       => $date
);

?
1 comment
Comment actions Permalink

Hi Michał,

Almost. You can have such allignment (use option below) but not with such big gap between key and value -- it will be alligned on longest key, but will not add extra spaces like you have in your example.

Settings | Code Style | PHP | Other | Align key-value pairs

The above option will make this:

$changes = array(
     'status' => 'PDF print',
     'who'    => $user,
     'email'  => $email,
     'phone'  => $phone,
     'date'   => $date
);

while you asking for this (your own example):

 $changes = array(
     'status'     => 'PDF print',

     'who'        => $user,
     'email'      => $email,
     'phone'      => $phone,
     'date'       => $date
);
0

Please sign in to leave a comment.