user3100345
user3100345

Reputation: 41

Convert Json to PHP Array

I have working code,

$output=json_encode($data);
$results=json_decode($output, TRUE);

foreach ($results['results'] as $id) {
    echo $id['id'] . '<br/>';
}

But what i am trying to do is list not only the ID's of the JSON output but also the "subject" Associated with each ID right next or below it. not sure how to do so.

Upvotes: 0

Views: 68

Answers (2)

user3100345
user3100345

Reputation: 41

  echo "<form action=\"former.php\" method=\"post\">";
  echo '<input type="text" name="TicketID" value="'. $item['id'] .'"/>';
  echo "<input type=\"submit\" name=\"View\" value=\"View\" />";

the Above is working for me BUT it wont let me view the Specific ID . it just defaults to the last ID in the array. @veNuker

Upvotes: 0

lchachurski
lchachurski

Reputation: 1800

Try this

foreach ($results['results'] as $item) {
  echo 'id: '. $item['id'] . ' subject: '. $item['subject'] .'<br/>';
}

Upvotes: 2

Related Questions