Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to retrieve PHP array in iOS
    primarykey
    data
    text
    <p>I want to retrieve data from Array in iOS sent from PHP webservice. Following is the structure of the Array:</p> <pre><code>[ { "fullname": "Kate Bell", "email": "kate-bell@mac.com" }, { "fullname": "Kate Bell", "email": "www.creative-consulting-inc.com" }, { "fullname": "Daniel Higgins", "email": "d-higgins@mac.com" }, { "fullname": "John Appleseed", "email": "John-Appleseed@mac.com" } ] </code></pre> <p>Note: Array can be of any length.</p> <p>PHP code:</p> <pre><code>mysql_select_db("mydb"); $ReturningArray = array(); foreach($Contacts_Array as $arr) { foreach($arr['emails'] as $email_address) { $query = "select email from table where email='".$email_address."'"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); if(empty($row)) { $Contact = array( "fullname" =&gt; $arr['fullname'], "email" =&gt; $email_address ); $ReturningArray[] = $Contact; } } } echo json_encode($ReturningArray); </code></pre> <p>Update:</p> <p>I have tried this code but it doesn't work</p> <pre><code> -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { // NSString *Result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; // NSLog(@"Result in NonTroopeUsers : %@",Result); NSArray *array = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil]; NSLog(@"COUNT :%d",[array count]); for (NSDictionary* item in array) { NSString *fullname = [item objectForKey:@"fullname"]; NSString *email = [item objectForKey:@"email"]; NSLog(@"Full name: %@",fullname); NSLog(@"email: %@",email); } } </code></pre> <p>Array count is Zero but the commented code shows data recieved in nslog.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload