json_encode() to convert data to stringJson is a data exchange format like XML. You can learn about Json support of PHP here.json_encode function takes data and converts them to a string, we call it as Json string. This string format follows a standard so it can be decoded back to its original data form at the receiving end. Example 1 : PHP Class data
Output is here
Example 2 : PHP Array data
The output of the above code is here.
This is one of the simple requirements, so we will try some complex than this by using two arrays.
The output of the above code is here.
You can start from here making your json string to exchange data across pages.
You can use database records to create JSons string and pass the data to different pages. Download the zip file to check the demo scripts using student table data to create Json string.
This article is written by plus2net.com team.
![]() |
▼ Click for more tutorial on Ajax & PHP |