-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,253
  • 13
  • 29

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
  • 481
  • 12
  • 19