如何将PHP mysql_fetch_array()转换为NSMutableArray?PHP-->;Xcode

如何将PHP mysql_fetch_array()转换为NSMutableArray?PHP-->;Xcode,php,mysql,objective-c,xcode,Php,Mysql,Objective C,Xcode,我试图使用PHP将整行从mysql读入NSMutableArray 示例PHP代码 <?php $con = mysql_connect("localhost", "username", "password"); if (!$con) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db("test_db",$con); $sql = "SELECT * from Pers

我试图使用PHP将整行从mysql读入
NSMutableArray

示例PHP代码

<?php
$con = mysql_connect("localhost", "username", "password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

$db_selected = mysql_select_db("test_db",$con);
$sql = "SELECT * from Person WHERE Lastname='smith'";
$result = mysql_query($sql,$con);
echo(mysql_fetch_array($result));

mysql_close($con);
?>
如何从mysql读取该数组,并将其存储为
NSMutableArray

到目前为止,我只知道如何使用以下命令从PHP接收字符串:

//to execute php code
NSData *dataURL = [NSData dataWithContentsOfURL: [NSURL URLWithString:strURL]];

//to receive the returned value
NSString *strResult = [[NSString alloc] initWithData:dataURL encoding: NSUTF8StringEncoding];

但我不知道如何读取数组并将其转换为
NSMutableArray
。我花了几个小时寻找,却找不到答案。我宁愿不使用JSON,而坚持使用Mysql/PHP/Obj-c

这并不是简单的ehh。您必须将HTML数据转换为iOS能够理解的格式。当然,如果您执行$result数组的
var\u dump()
,iOS就无法理解!您必须将字符串转换为JSON或XML等通用格式,然后下载数据。因此,当iOS接收到JSON/XML时,您可以使用反射或其他方法来处理它,以重现JSON对象

//to execute php code
NSData *dataURL = [NSData dataWithContentsOfURL: [NSURL URLWithString:strURL]];

//to receive the returned value
NSString *strResult = [[NSString alloc] initWithData:dataURL encoding: NSUTF8StringEncoding];