How to convert JSON string to array using php

In this tutorial learn How to convert JSON string format to array format in php, here more with the example.

Convert JSON string to array using php



    echo "json =>  ". $str='{"data":[{"id":"2","qty":"10","size":"1,2,3"},                                 {"id":"3","qty":"4","size":"1,2,3"}]}';

    $data = json_decode($str, TRUE);

    echo "<pre>";
    print_r($data);
    foreach ($data as $key => $value) {
          echo "Convert into string <br>";
             foreach ($value as $key => $values) {
                  foreach ($values as $key => $v) {
                  echo $key."==>" .$v;

          }
          echo "<br>";
    }
}
    





No comments:

Post a Comment

how to call ssh from vs code

 To call SSH from VS Code, you can use the built-in Remote Development extension. This extension allows you to open a remote folder or works...