1

Mandrill app return this : [{"email":"steven@gmail.com","status":"sent","_id":"234we4fvba4a3e8517d7a9","reject_reason":null}]

I need to get only the value of "status". Something like this: echo $result['status']; How can I do it in PHP?

Turnerj
  • 4,258
  • 5
  • 35
  • 52
batMask
  • 734
  • 3
  • 17
  • 35

2 Answers2

2

use json_decode() to get the status.. like this :

<?php

$str = '[{"email":"steven@gmail.com","status":"sent","_id":"234we4fvba4a3e8517d7a9","reject_reason":null}]';
$json = json_decode($str, true);
echo $json[0]['status'];

 ?>
Manjeet Barnala
  • 2,975
  • 1
  • 10
  • 20
0

you can use like

$json = '[{"email":"steven@gmail.com","status":"sent","_id":"234we4fvba4a3e8517d7a9","reject_reason":null}]';
$json_array = json_decode($json);
print "<pre>";print_r($json_array[0]->status);
Brijal Savaliya
  • 1,101
  • 9
  • 19