json_encode to convert data to stringJson is a data exchange format like XML. You can learn about Json support of PHP here. We will learn about php function json_encode() here. This function is built in higher versions of PHP. To know about support of your PHP version regarding Json you can check the Json Introduction page.
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.
Let us start with an array of data. Here is an simple data array in PHP, we will apply json_encode() to this array.
The output of the above code is here.
Ajax & PHP scripts Creating XMLHttp object in different browsers Sample Code: Get Method of Ajax form submission Server Clock:: Display real-time date and time of server Dependant drop down list box using Ajax & PHP Email validation using Ajax in a form Getting customer details by entering customer id using Ajax Progress Bar using Ajax Progress Bar using MySQL PHP & Ajax Displaying Message at client side using Ajax & PHP Web page HTML form validation using Ajax and PHP Form validation with onBlur event using Ajax and PHP
Json support in PHP json_encode to generate Json string from PHP Array data Json Data formatting to return database records to main script Searching MySql database as we type using Ajax Displaying all records based on selection of a drop down list box