user2301515
user2301515

Reputation: 5117

PHP array's definitions possibilities

If i have some variables like $val1, $val2, $val3, ... and convert to arr

$arr = ['val1' => $val1, 'val2' => $val2, 'val3' => $val3,..];

is it possible to define a shortly this array like this?

$arr = a('val1', 'val2', 'val3', ..)

Upvotes: 0

Views: 39

Answers (1)

Pierre
Pierre

Reputation: 649

If keys are not important, you may write

$arr = [$val1, $val2, $val3];

or

$arr = array($val1, $val2, $val3);

Upvotes: 1

Related Questions