Hi Reader's,
Welcome to FindNerd, today we are going to discuss how to use json_encode() function in php ?
So, Firstly let us know what is the use of json_encode() function ?
JSON stands for JavaScript Object Notation. json_encode() is a PHP function that is used for converting the array given as its argument into a JSON string.
you can see bellow example:
<?php
//First you need a PHP array of data
$data = array(
'first_name' => "mac",
'last_name' => "heneary",
'phone_number' => 123456789,
'address' => "adayu"
);
//here call json_encode() function
$jsondata = json_encode($data);
//print json_encode data
print_r($jsondata);
?>
output will come following of above example
{"name":"mac","phone_number":123456789,"address":"adayu"}
0 Comment(s)