I know this is really thorough, but I searched everywhere, and I canβt find the right answer.
As for the previous question: How to format a list in PHP to be used as an NSArray in Objective-C?
I am trying to write a short PHP script (without knowing anything about it) that my iphone application will call to get a list of elements. I was thinking about using ECHO, since I really do not need to send more than one array of elements, but it was recommended to use JSON or XML, so I chose JSON.
I am looking for a way to encode an array in JSON, and the only thing I could find was json_encode, which does not seem to create a JSON structure. Here is my PHP code:
<?php
$arr = array ('a', 'b','c','d','e');
echo json_encode($arr);
?>
Is that what I should use? Am I doing something wrong? Many thanks.
EDIT:
This is the output when running this PHP script in the terminal:
["a", "b", "c", "g", "e"]
As far as I know, this is not a JSON structure, but then again, I don't know anything about it.