I am pulling JSON data from an API URL. I need to pull specific KEYS and put them into a table with columns and rows. 6 (col) x 20+ (rows). The KEYS are all duplicate (val,
I resolved this:
<style>
.uabb-table {
overflow-x: auto;
margin-left: auto;
margin-right: auto;
zoom: 1;
display: flex;
}
.uabb-table .uabb-table-element-box {
-webkit-flex-grow: 1;
-ms-flex-positive: 1;
-webkit-box-flex: 1;
flex-grow: 1;
}
.uabb-table .uabb-table-wrapper {
text-align: center;
position: relative;
height: 100%;
}
.uabb-table-inner-wrap {
width: 100%;
}
.fl-module-uabb-table .uabb-table-wrapper .uabb-table-inner-wrap {
border-collapse: collapse;
margin: 0;
}
.uabb-table .uabb-table-wrapper {
text-align: center;
position: relative;
}
.fl-module-uabb-table .uabb-table-wrapper .uabb-table-inner-wrap {
border-collapse: collapse;
margin: 0;
}
.uabb-table-inner-wrap .uabb-table-header .table-header-th {
border: 1px solid #000000;
padding: 15px;
}
.uabb-table .uabb-table-header .table-header-th {
overflow-wrap: normal;
}
.uabb-table .uabb-table-header .table-header-th, .uabb-table .uabb-table-features .table-body-td {
vertical-align: middle;
padding: 15px;
border: 1px solid #000000;
}
.uabb-table .uabb-table-header .table-header-tr .table-header-th .th-style .head-inner-text, .uabb-table .uabb-table-header .table-header-tr .table-header-th .th-style {
background: none;
}
.uabb-table .table-header-th .th-style {
padding-right: 15px;
}
label {
display: inline-block;
margin-bottom: .5rem;
}
.uabb-table .uabb-table-header .table-header-tr .table-header-th .th-style .head-inner-text, .uabb-table .uabb-table-header .table-header-tr .table-header-th .th-style {
background: none;
}
.content-text {text-transform: uppercase;}
</style>
<?php
$url = 'URL';
$data = file_get_contents($url);
$parsed = json_decode($data, true);
$eachEntry = $parsed['response']['result']['Leads']['row'];
$valuesIWant = ["First Name", "Last Name", "Street", "City", "State", "Zip Code"];
echo '<div class="uabb-table-module-content uabb-table">
<div class="uabb-table-element-box">
<div class="uabb-table-wrapper">
<table class="uabb-table-inner-wrap">
<thead class="uabb-table-header">
<tr class="table-header-tr">
<th class="table-heading-0 table-header-th" rowspan="" colspan="">
<label class="head-style-0 th-style">
<label class="head-inner-text">First Name</label>
</label>
</th>
<th class="table-heading-1 table-header-th" rowspan="" colspan="">
<label class="head-style-1 th-style">
<label class="head-inner-text">Last Name</label>
</label>
</th>
<th class="table-heading-2 table-header-th" rowspan="" colspan="">
<label class="head-style-2 th-style">
<label class="head-inner-text">Street</label>
</label>
</th>
<th class="table-heading-3 table-header-th" rowspan="" colspan="">
<label class="head-style-3 th-style">
<label class="head-inner-text">City</label>
</label>
</th>
<th class="table-heading-4 table-header-th" rowspan="" colspan="">
<label class="head-style-4 th-style">
<label class="head-inner-text">State</label>
</label>
</th>
<th class="table-heading-5 table-header-th" rowspan="" colspan="">
<label class="head-style-5 th-style">
<label class="head-inner-text">Zip Code</label>
</label>
</th>
</tr>
</thead>';
foreach ($eachEntry as $entry) {
$FL = $entry['no'];
//printf("\n");
$entries = $entry['FL'];
echo '<tbody class="uabb-table-features"><tr class="tbody-row">';
foreach ($entries as $value) {
$val = $value['val'];
$content = $value['content'];
if (in_array($val, $valuesIWant)) {
//$out = $val;
$out2 = $content;
//echo '<td>'. $out .'</td>';
echo '<td class="table-body-td table-body-0" colspan="" rowspan=""><span class="content-text">'. $out2 .'</span></td>';
}
}
echo '</tr></tbody>';
}
echo '</table></div></div></div>';
?>