How To Use Parse a JSON File Using PHP?

PHP

Nicesnippets

05-01-2022


How To Use Parse a JSON File Using PHP?

Hello Friends,

In this post, i will show you parse a json file php. We will to parse a json file in php. We will show how to use how to get data from json array in php. This article will give you how to get data from json object in php.

In this tutorial, I would like share with you to get data from json array in php. how to setup php parse a json file example.I will show you how to parse a json file in php

Here i will give you many example how to parse a json file php.

So let's see bellow solution:

Example : 1


<?php

// Using json_encode() Function.

$array = ['Name'=>'Nicesnippets','Subject'=>'php','Class'=>'Bca'];

$json_formate = json_encode($array);

echo $json_formate;

?>

Output:

{

"Name":"Nicesnippets",

"Subject":"php",

"Class":"Bca"

}

Example : 2

<?php

// Using json_decode() Function

$json = '{

"Name":"Nicesnippets",

"Subject":"php",

"Class":"Bca"

}';

var_dump(json_decode($json));

?>

Output:

object(stdClass)#1 (3) { ["Name"]=> string(6) "Nicesnippets" ["Subject"]=>string(3) "php" ["Class"]=> string(3) "Bca" }


Recommended Posts