Skip to content
Advertisement

PHP and adding same value to several array keys

I’m using PHP. I would like to add same value to several array keys.

This works:

JavaScript

Anyway, I’m looking for a shorter way. So, I have tried this:

JavaScript

This did not work at all.

Any ideas how the job could be done with less code?

Advertisement

Answer

the obvious and most readable variant is:

JavaScript

another option is:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement