-3

The Json

data ={
"2":
  {
    "routtype":"Transactional", 
    "credit":40000,
    "validity":"4616",
    "availablecredit":"39457"
  }
}

how to extract this data into variable one by one

Ritesh Khatri
  • 1,111
  • 11
  • 24

1 Answers1

2

assuming $json_array as your array.

$data = json_decode($json_array); 
foreach($data as $dt){
    $routtype = $dt->routtype;
    $credit = $dt->credit;
    $validity = $dt->validity;
    $availablecredit = $dt->availablecredit;
    echo $routtype;
    echo $credit;
    echo $validity;
    echo $availablecredit;
}
romal tandel
  • 473
  • 11
  • 18