Declare and assign arrays in chain?

  php

In PHP i believe i can declare/assign variables in chain, like so:

$a = $b = $c = 2;

My question is if this can also be applied to arrays.

Can i declare arrays like this?

$album_rows = $image_rows = [];

And assign them like so:

...
$album_rows = $image_rows =  $result->fetch_all(MYSQLI_ASSOC);
...

I’ve tried and it seems to work, but I’m not sure if this is good practice or this is a big No! No!

Source: Ask PHP

LEAVE A COMMENT