Maybe this isn't possible, I've never seen it myself, but thought I'd ask. If this is my array,
$myarr = array(
'red' => 7,
'green' => 7,
'blue' => 18,
'cyan' => 14,
'pink' => 18
'brown' => 18
);
is there a way while initializing the array to set similar values at once? like
'red' && 'green' =>7,
'blue' && 'pink' && 'brown' => 18,
'cyan' =>14
of course I'm not expecting this syntax to work but is there something that gets me the same idea?
PHP Manual does not provide description of any way to do that. BTW, you may initialize values in the following way:
$myarr['red'] = $myarr['green'] = 7;
$myarr['blue'] = $myarr['pink'] = $myarr['brown'] = 18;
$myarr['cyan'] = 14;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With