'Pushing data in keys into a single array only values
Such data is coming from Laravel to Ajax. How do I push the values inside the keys into a single array without the keys.
$get_session = session()->get('cart.products');
return response($get_session);
Data returned to Ajax.
data1: {
1234543: {id: 1, title: 'Product Title1', description: 'Product Descrition1'}
3453234: {id: 2, title: 'Product Title2', description: 'Product Descrition2'}
4564234: {id: 3, title: 'Product Title3', description: 'Product Descrition3'}
}
data2: {
4643345: {id: 4, title: 'Product Title4', description: 'Product Descrition4'}
8679673: {id: 5, title: 'Product Title5', description: 'Product Descrition5'}
2344565: {id: 6, title: 'Product Title6', description: 'Product Descrition6'}
}
this is what i want to do
[
1234543: {id: 1, title: 'Product Title1', description: 'Product Descrition1'}
3453234: {id: 2, title: 'Product Title2', description: 'Product Descrition2'}
4564234: {id: 3, title: 'Product Title3', description: 'Product Descrition3'}
4643345: {id: 4, title: 'Product Title4', description: 'Product Descrition4'}
8679673: {id: 5, title: 'Product Title5', description: 'Product Descrition5'}
2344565: {id: 6, title: 'Product Title6', description: 'Product Descrition6'}
]
How can I do it with Laravel or jquery? Thanks everyone.
Solution 1:[1]
try this
return response()->json([$get_session['data1']]);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | shahriyar3 |