json_encode() to convert data to string

Json 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

$my_data = new stdClass();

echo $out_data;
Output is here

Example 2 : PHP Array data

echo json_encode($a);
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.
$my_data = new stdClass();


echo json_encode($out_data);
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.

json data formatting
Json XML Ajax
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net


    Post your comments , suggestion , error , requirements etc here

    PHP video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer