So I'm completely new to PHP. In fact, I do not know anything about this. I am developing an application for the iPhone and trying to get a list of items from the server. My PHP script is literally just an echo command.
I was wondering what would be the best way to format my list in PHP so that it looks as close as possible (if not identical) to an NSArray in a C.
So for example if my list is: AAA, BBB, CCC, DDD
By running this in obj-C:
NSArray *myAwesomeArray = [[NSArray alloc] initWithObjects: @"AAA", @"BBB", @"CCC", @"DDD", nil];
I will get this what I want:
myAwesomeArray IS (
AAA,
BBB,
CCC,
DDD
)
When you do this with PHP, like this (again, maybe the formatting is wrong for this purpose):
echo "AAA, BBB, CCC, DDD"
And this is on the objc side:
NSString *urlString = @"http://......";
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]init];
[request setTimeoutInterval:60.0];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
NSString *myPHPArray = [[NSString alloc] initWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil] encoding:NSUTF8StringEncoding];
NSArray *myArray = [myPHPArray componentsSeparatedByString:@","];
I get this in objc for myArray:
myArray is (
AAA,
" BBB",
" CCC",
" DDD "
)
which is a little spoiled ...
Appreciate any help. thank you