I have JSON objects array as shown below. The following JSON objects array is in the file (process/ptp-hello.json)
{
"list": ["1", "2"],
"code": ["ABCD", "DEFG", "PQRT", "KJHG", "OOPO", "MNBG", "IUYT"]
}
Php code:
<?php
if (file_exists('process/ptp-hello.json')) {
$letter = json_decode(file_get_contents('process/ptp-hello.json')); // Line A
}
?>
<?php foreach ($letter->list as $key => $value) { ?>
<a href="/en/?s=&port=<?php echo $letter->code[$value]; ?>">
<div class="beats">
<div class="color-green"><?php echo $letter->code[$value]; ?></div> // Line B
</div>
</a>
<?php }
Line B prints DEFG and PQRT
Problem Statement:
I am wondering what changes I should make in the php code above so that it prints ABCD, KJHG, OOPO, MNBG and IUYT.
In short, I want to remove those elements from code
whose indices are listed in list
It should be as simple as
This returns
You can do a lot with the return, make a new array, echo out information, whatever you'd like to do.