Json

I have the following if json returns suscessful


// Process your response here
	$jsonData = json_decode($response);

if ($jsonData->status === 'success') {
echo ('Sent');

I need to also get the id number that will be in the returned value

{
	"balance":1162,
	"batch_id":123456789,
	"cost":2,
	"num_messages":2,
	"message":{
		"num_parts":1,
		"sender":"Rob",
		"content":"This is your message"
	},
	"messages":[{
		"id":"1151346216",
		"recipient":447123456789
	},
	{
		"id":"1151347780",
		"recipient":447987654321
	}],
	"status":"success"
},

i want to get the id value and set that as a variable id how would i go about this.

which id do you want? the batch_id or the id of each message in the messages array?

Id of the message

// Process your response here 
    $jsonData = json_decode($response); 

if ($jsonData->status === 'success') { 
  foreach($jsonData->messages as $message)
  {
    echo $message->id;
  }

Cheers for your help much appriciated!