What is Php json?

0 votes
what is the function that can be used in php json?
3 days ago in PHP by anonymous
• 1,910 points
13 views

1 answer to this question.

0 votes

Hii @kartik,

JSON stands for JavaScript Object Notation, and is a syntax for storing and exchanging data.

Since the JSON format is a text-based format, it can easily be sent to and from a server, and used as a data format by any programming language.

PHP has some built-in functions to handle JSON.

First, we will look at the following two functions:

  • json_encode()
  • json_decode()

PHP - json_encode()

The json_encode() function is used to encode a value to JSON format.

Example

This example shows how to encode an associative array into a JSON object:

<?php
$age = array("Peter"=>35, "Ben"=>37, "Joe"=>43);

echo json_encode($age);
?>

PHP - json_decode()

The json_decode() function is used to decode a JSON object into a PHP object or an associative array.

Example

This example decodes JSON data into a PHP object:

<?php
$jsonobj = '{"Peter":35,"Ben":37,"Joe":43}';

var_dump(json_decode($jsonobj));
?>
answered 3 days ago by Niroj
• 3,230 points

Related Questions In PHP

0 votes
1 answer

How can we avoid my php form from hacking?

Hii @kartik, If you want to know php ...READ MORE

answered 4 days ago in PHP by Niroj
• 3,230 points
15 views
0 votes
1 answer

How to Validate Form Data With PHP?

Hey @kartik, The first thing we will do ...READ MORE

answered 4 days ago in PHP by Niroj
• 3,230 points
11 views
0 votes
1 answer

How to validate E-mail and URL of Php form?

hey, The code below shows a simple way ...READ MORE

answered 4 days ago in PHP by manish
21 views
+1 vote
1 answer

What is the relationship between angularjs Scope with controller/view?

Let us consider the below block: <div ng-controller="emp"> ...READ MORE

answered Jan 20 in Web Development by Niroj
• 3,230 points

edited Jan 21 by Niroj 29 views
+1 vote
1 answer

What is css box module?

Hey, All the element present in html follows ...READ MORE

answered Jan 20 in Web Development by Niroj
• 3,230 points

edited Jan 21 by Niroj 30 views
0 votes
1 answer

Explain the difference between visibility:hidden; and display:none?

hii, visibility:hidden; and display:none are totally different used ...READ MORE

answered Jan 20 in Web Development by Niroj
• 3,230 points
57 views
+1 vote
1 answer

How to access the Angularjs scope of a particular html element from our console?

Hello, You should follow the below steps:-- 1.Compile and ...READ MORE

answered Jan 21 in Web Development by Niroj
• 3,230 points

edited Jan 21 by Niroj 31 views
0 votes
1 answer

What is a Cookie? How to create Cookies With PHP?

A cookie is often used to identify ...READ MORE

answered 4 days ago in PHP by Niroj
• 3,230 points
16 views
0 votes
1 answer

What are the vulnerability related to PHP Form?

Hii, The $_SERVER["PHP_SELF"] variable can be used by ...READ MORE

answered 4 days ago in PHP by Niroj
• 3,230 points
12 views
0 votes
1 answer

What is the simplest way to read JSON from a URL in java

Read json from url use url.openStream() and read contents ...READ MORE

answered Jun 13, 2018 in Java by samarth295
• 2,190 points
718 views