RE: How to convert array to json in php?

How to convert array to json in php?

B Mathur Team Leader Asked on February 11, 2017 in JSON.
Add Comment
1 Answers

json_encode() — Returns the JSON representation of a value


<?php

$array = array('a' => 10, 'b' => 20, 'c' => 30, 'd' => 40);
echo json_encode($array);

?>


Output:


{"a":10,"b":20,"c":30,"d":40}

Team Leader Answered on March 14, 2017.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.