Here's an example of the input JSON array:
"tags":[{"id":1306,"accountID":4936,"name":"BURTON","group":"Rep","type":0,
"dateCreated":"2015-07-09 19:38:46","dateModified":"2016-04-15 15:02:00",
"isDeleted":false,
"isActive":true,"numOrders":0,"abort":false,
"currentClass":"Tag","_jsonSkipsReadOnly":false}],
Here is the PHP that will pull out the first 3 records of the tags JSON array. I realize that it would be better to create a PHP array for tags instead
foreach ($tagsarray as $tags) { for ($i=1; $i<4; $i++) { ${'tagid'.$i} = $tags->id; ${'tagname'.$i} = $tags->name; ${'taggroup'.$i} = $tags->group; } //echo "tagname1: ".$tagname1."tagname2: ".$tagname2."tagname3: ".$tagname3."
"; // do nothing after capturing first 3 tags records }
foreach ($tagsarray as $tags) { $tagid[] = $tags->id; $tagname[] = $tags->name; $taggroup[] = $tags->group; } $tagid1 = $tagid[0]; $tagname1 = $tagname[0]; $taggroup1 = $taggroup[0]; $tagid2 = $tagid[1]; $tagname2 = $tagname[1]; $taggroup2 = $taggroup[1]; $tagid3 = $tagid[2]; $tagname3 = $tagname[2]; $taggroup3 = $taggroup[2];
No comments:
Post a Comment