Answers for "collections to array php"

PHP
0

php collection to array

//convert a collection toArray()
$comments_collection = $post->comments()->get()->toArray()
Posted by: Guest on September-11-2021
5

php collection to array

$collection = collect([
    ['product_id' => 'prod-100', 'name' => 'Desk'],
    ['product_id' => 'prod-200', 'name' => 'Chair'],
]);

$plucked = $collection->pluck('name');

$plucked->all();

// ['Desk', 'Chair']
Posted by: Guest on May-21-2020
0

php array to array collection

$collection = new ArrayCollection($allQuestions);
Posted by: Guest on July-04-2021

Browse Popular Code Answers by Language