How to bring the object right under his id?

0 like 0 dislike
8 views
There is an object
$categories store name and id you can access them in a foreach.
And how to deduce the name on the id? That is, in the PLO to make such
$categories[0] - will display the name and so on.
UP: for understanding I have id 1 and 4
You can get id to name?
$categories = DB::table('category')->get(); foreach($categories as $category){ $sub[$category->id] = $category->name; }

But then spike.
by | 8 views

1 Answer

0 like 0 dislike
Here is a direct answer to the question on stackoverflow
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
4 answers
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
33,911 users