Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

How do i make my own php page to send the json data I want?

In the blog reader app we learn how to request and handle json data. How do i make my own php page to send the json data I want?

2 Answers

Hi Stephen,

The most basic example would be to JSON encode an array and echo it out to the page, for example.

<?php

$data = array('key' => 'value');
echo json_encode($data);

I should have been clearer. I meant an array inside an array like the sample data for the project. i.e. status = ok name = treehouse cnt = 10 post = title= yes you can author = me date = 12-4-81

title= no you cant author = you date = 12-10-81

title= you might author = someone date = 12-25-82