-2

我将此结果作为 mysql_fetch_row 函数从数据库返回行...

Array
(
    [firstname] => abc
    [lastname] => xyz
    [password] => abc
    [gender] => female
    [city] => malborne
    [email] => abc@gmail.com
    [address] => abc
)

我想要这个数组作为

Array
(
  [0] array(


        [firstname] => abc
        [lastname] => xyz
        [password] => abc
        [gender] => female
        [city] => malborne
        [email] => abc@gmail.com
        [address] => abc

)
)
4

3 回答 3

1
$newArray = array($data);
print_r($newArray);

输出:

Array
(
    [0] => Array
        (
            [firstname] => abc
            [lastname] => xyz
            [password] => abc
            [gender] => female
            [city] => malborne
            [email] => abc@gmail.com
            [address] => abc
        )

)

达达!

于 2013-08-09T05:59:19.623 回答
0

这很容易,您可以通过将其插入另一个数组来创建所需的结构

$original = array(.....);
$final = array($original);
于 2013-08-09T05:56:07.220 回答
0
$myArray = array();

while($row = mysql_fetch_row(...)) {
  $myArray[] = $row;
}
// $myArray is your final array
于 2013-08-09T05:57:26.397 回答