<?php
$json = '{
"type": "the type",
"typesm": "type of",
"entries": [
{
"title": "title one",
"body": "Original text",
"image": "image 1 url",
"time": "1558532690",
"meta": {
"mainColor": "#100a0e",
"adSpace": null
}
},
{
"title": "title two",
"body": "Original text",
"image": "image 1 url",
"time": "1558515409",
"meta": {
"mainColor": "#100a0e",
"adSpace": null
}
}]}';
$arr = json_decode($json, true);
$arr['entries'] = array_column($arr['entries'], null, 'body');
foreach ($arr['entries'] as $ent){
echo $ent['image']. "\n";
echo $ent['title']. "\n";
echo $ent['body']. "\n";
}
unset($ent);
Echo "\n\n\n";
$arr = json_decode($json, true);
foreach($arr['entries'] as $e){
$ent[$e['body'] . " " . $e['image']] = $e;
}
//$ent is now the new array with unique values of 'entries'
foreach ($ent as $e){
echo $e['image'] . "\n";
echo $e['title'] . "\n";
echo $e['body'] . "\n";
}
- Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- image 1 url
title two
Original text
image 1 url
title two
Original text
preferences:
167.41 ms | 403 KiB | 211 Q