php (laravel) short hand for creating an array with elements has id property
I want to create an array like this
$a = [
['id' => 1],
['id' => 2],
['id' => 3],
['id' => 4],
....
]
just like array_fill but with id property for each element
I known I could do it by loop and map function but I wonder if there is a short hand for this. I’m using php laravel framework. thanks in advance
from Laravel Questions and Answers https://laravelquestions.com/php/php-laravel-short-hand-for-creating-an-array-with-elements-has-id-property/
via Lzo Media
No comments:
Post a Comment