Awesome q2a theme

How to pull data out of a multidimensional array?

0 like 0 dislike
23 views
Hello! Seemingly noob question, but is confused and can't understand how forcem (or framework) to properly display data from the database.
In the database model data stored by the collection and get an array ($casts).
The table has 3 columns: name, age, work.

"name" => array:3 [▼ 0 => "Andrey
" 1 => "Aleksandr
" 2 => "Petr
" ] "age" => array:3 [▼ 0 => "18" 1 => "29" 2 => "38" ] "work" => array:3 [▼ 0 => "Manager" 1 => "Driver" 2 => "Cleaner" ]


How to bring the data to get 3 records, type:
Name: name
Age: age
Work: work

Name: name
Age: age
Work: work

Name: name
Age: age
Work: work

Maybe there is a possibility of tools laravel to do this?
In advance thanks all responded to my problem!
by | 23 views

1 Answer

0 like 0 dislike
for example , like this :
$result = []; foreach( $name as $key=>$value){ $result[] = ['name'=>$value, 'age' =>age[$key], 'work'=> work[$key] ; ]; } this is assuming that all 3 arrays all relevant records available. Ie the same everywhere, the number of items in the correct order
by

Related questions

0 like 0 dislike
2 answers
asked Apr 12, 2019 by smoln
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
asked May 22, 2019 by lompas23
110,608 questions
257,187 answers
0 comments
40,796 users