Aug 9, 2018
0
Level 1
How to merge an array IF....
Good day, How can I merge an array if the po_id is the same with the other row object?
for example:
[
{
"po_id": 42,
"full_name": "Sample Zample",
"product_name": "School Owner Manual Payment School Owner Manual Payment",
"level": "school",
"date_purchase": "2018-08-09 14:53:35",
"student_name": "Sample Student1",
"item_status": 2
},
{
"po_id": 42,
"full_name": "Sample Zample",
"product_name": "School Owner Manual Payment School Owner Manual Payment",
"level": "school",
"date_purchase": "2018-08-09 14:53:35",
"student_name": "Sample Student2",
"item_status": 2
},
{
"po_id": 42,
"full_name": "Sample Zample",
"product_name": "School Owner Manual Payment School Owner Manual Payment",
"level": "school",
"date_purchase": "2018-08-09 14:53:35",
"student_name": "Sample Student3",
"item_status": 2
},
{
"po_id": 43,
"full_name": "Zample Sample",
"product_name": "School Owner Manual Payment School Owner Manual Payment",
"level": "school",
"date_purchase": "2018-08-09 14:53:35",
"student_name": "Sample Student1",
"item_status": 2
},
]
desired output should look like this.
[
{
"po_id": 42,
"full_name": "Sample Zample",
"product_name": "School Owner Manual Payment School Owner Manual Payment",
"level": "school",
"date_purchase": "2018-08-09 14:53:35",
"student_name": [
"Sample Student1",
"Sample Student2",
"Sample Student3"
],
"item_status": [
2,
3,
4
]
},
{
"po_id": 43,
"full_name": "Zample Sample",
"product_name": "School Owner Manual Payment School Owner Manual Payment",
"level": "school",
"date_purchase": "2018-08-09 14:53:35",
"student_name": "Sample Student",
"item_status": 2
}
]
Please or to participate in this conversation.