Я извлекаю данные JSON из URL-адреса API.Проблема: в FL есть дубликаты KEYS: «val» и «content».Мне нужно только нажать определенные КЛЮЧИ.
Пожалуйста, извините, если мое форматирование не соответствует стандартам SO. *
Мой вопрос размещен ниже json и кода.
JSON ОТ URL
{
"response": {
"result": {
"Leads": {
"row": [
{
"no": "1",
"FL": [
{
"val": "LEADID",
"content": "123"
},
{
"val": "SMOWNERID",
"content": "3232"
},
{
"val": "Lead Owner",
"content": "Cassie"
},
{
"val": "First Name",
"content": "Bobby"
},
{
"val": "Last Name",
"content": "Something"
},
{
"val": "Email",
"content": "email@gmail.com"
},
{
"val": "Mobile",
"content": "1111111111"
},
{
"val": "SMCREATORID",
"content": "0000003213"
},
{
"val": "Created By",
"content": "Cassie"
},
{
"val": "Created Time",
"content": "2019-04-03 15:14:05"
},
{
"val": "Modified Time",
"content": "2019-04-03 17:13:58"
},
{
"val": "Full Name",
"content": "Bobby Something"
},
{
"val": "Street",
"content": "123 Fake Rd"
},
{
"val": "City",
"content": "Fakecity"
},
{
"val": "State",
"content": "FK"
},
{
"val": "Zip Code",
"content": "11111"
},
{
"val": "Email Opt Out",
"content": "false"
},
{
"val": "Salutation",
"content": "Mr."
},
{
"val": "Last Activity Time",
"content": "2019-04-03 17:13:58"
},
{
"val": "Tag",
"content": "Tag"
},
{
"val": "Account Name",
"content": "Something"
},
{
"val": "Territory Manager",
"content": "Michael Something"
},
{
"val": "Territory Manager_ID",
"content": "321237000000291111"
},
{
"val": "Classification",
"content": "Something"
},
{
"val": "Area",
"content": "Zone 1"
},
{
"val": "Account Number",
"content": "32345"
}
]
}
]
}
},
"uri": "/crm/private/json/Leads/getRecords"
}
}
КОД PHP
$url = 'URL';
$data = file_get_contents($url);
$parsed = json_decode($data, true);
$eachEntry = $parsed['response']['result']['Leads']['row'];
foreach ($eachEntry as $entry) {
$FL = $entry['no'];
//printf('%s'.PHP_EOL, $FL);
printf("\n");
$entries = $entry['FL'];
foreach ($entries as $value) {
$val = $value['val'];
$content = $value['content'];
$out = $val." ".$content;
printf('%s'.PHP_EOL, $out);
printf("\n");
}
}
РЕЗУЛЬТАТЫ
LEADID 123
SMOWNERID 3232
Lead Owner Cassie
First Name Bobby
Last Name Something
Email email@gmail.com
Mobile 1111111111
SMCREATORID 0000003213
Created By Cassie
Created Time 2019-04-03 15:14:05
Modified Time 2019-04-03 17:13:58
Full Name Bobby Something
Street 123 Fake Rd
City Fakecity
State FK
Zip Code 11111
Email Opt Out false
Salutation Mr.
Last Activity Time 2019-04-03 17:13:58
Tag Tag
Account Name Something
Territory Manager Michael Something
Territory Manager_ID 321237000000291111
Classification Something
Area Zone 1
Account Number 32345
ВОПРОС
Как я могу получить только те поля, которые я перечислилниже в примере?И не тяните каждое поле.
ПРИМЕР
"val": "First Name",
"content": "Bobby"
,
"val": "Last Name",
"content": "Something"
,
"val": "Street",
"content": "123 Fake Rd"
,
"val": "City",
"content": "Fakecity"
,
"val": "State",
"content": "FK"
,
"val": "Zip Code",
"content": "11111"
ОЖИДАЕМЫЙ ВЫХОД
First Name Bobby
Last Name Bobby
Street 123 Fake Rd
City Fakecity
State FK
Zip Code 11111
Установка JSON из URL в таблицу HTML
PHP JSON для массива значений в таблицу HTML