我有一个json格式如下
{
"results": [
{
"url": "someurl",
"imageUrl": "somepath",
"tickets": [
{
"id": 98655,
"name": "ADULT TICKET",
"soldOut": false,
"provisionallySoldOut": false,
"price": 100,
"salesStart": "2018-06-26T11:52:00",
"salesEnd": "2018-07-28T17:00:00",
"description": "",
"donation": false,
"vendorTicket": false
},
{
"id": 98656,
"name": "UNDER 12",
"soldOut": false,
"provisionallySoldOut": false,
"price": 80,
"salesStart": "2018-06-26T11:53:00",
"salesEnd": "2018-07-28T17:00:00",
"description": "",
"donation": false,
"vendorTicket": false
}
]
},
{
"url": "someurl",
"imageUrl": "somepath",
"tickets": [
{
"id": 98735,
"name": "ADULT EARLY BIRD",
"soldOut": false,
"provisionallySoldOut": false,
"price": 150,
"salesStart": "2018-06-26T12:47:00",
"salesEnd": "2018-08-12T10:00:00",
"description": "",
"donation": false,
"vendorTicket": false
},
{
"id": 98736,
"name": "UNDER 12 - EARLY BIRD",
"soldOut": false,
"provisionallySoldOut": false,
"price": 120,
"salesStart": "2018-06-26T12:47:00",
"salesEnd": "2018-08-12T10:00:00",
"description": "",
"donation": false,
"vendorTicket": false
}
]
}
],
"pageSize": 10,
"pages": 1,
"records": 2,
"extras": null,
"message": null,
"statusCode": 0
}
我的数据库中有一个表,名为“event\ u tickets”,表中有“name”和“price”两列,我想在同一列中显示成人票和12岁以下儿童票的名称,在同一列中用逗号分隔,在“price”下用逗号分隔,在同一列中显示prices 100和80
我希望它在我的表上显示类似的内容。为了更清楚地说明这一点,我希望使用php插入上表中提到的值。表格格式应该是这样的
name | price
ADULT TICKET,UNDER 12 | 100,80
ADULT EARLY BIRD, UNDER 12 - EARLY BIRD | 150,120
有什么方法可以用php实现吗?
因为当我试着运行我的代码时,名字显示在不同的栏中,价格显示在不同的栏中
提前谢谢
1条答案
按热度按时间fd3cxomn1#
php中的一个解决方案: