我想将MySQL结果转换为PHP数组,然后在我的代码中使用该数组:
git clone https://github.com/phpmyadmin/phpmyadmin.git
如何将MySQL结果分配到while( $row = mysqli_fetch_assoc($res) ) {
$data[] = $row;
}
print_r($data);
$data = Array
(
[0] => Array
(
[id] => 1,
[name] => MySQL,
[text] => MySQL,
[href] => ,
[parent_id] => 0,
)
[1] => Array
(
[id] => 2,
[name] => Java
[text] => Java
[href] => ,
[parent_id] => 0
)
[2] => Array
(
[id] => 3
[name] => PHP
[text] => PHP
[href] => ,
[parent_id] => 0
)
[3] => Array
(
[id] => 4
[name] => PHP Tutorial
[text] => Tutorial
[href] => ,
[parent_id] => 3
)
[4] => Array
(
[id] => 5
[name] => PHP Script
[text] => Script
[href] => ,
[parent_id] => 3
)
[5] => Array
(
[id] => 6
[name] => Email
[text] => Email
[href] => ,
[parent_id] => 5
)
[6] => Array
(
[id] => 7
[name] => Java Tutorial
[text] => Tutorial
[href] => ,
[parent_id] => 2
)
[7] => Array
(
[id] => 8
[name] => Java Resources
[text] => Resources
[href] => ,
[parent_id] => 2
)
[8] => Array
(
[id] => 9
[name] => MySQL Tutorial
[text] => Tutorial
[href] => ,
[parent_id] => 1
)
[9] => Array
(
[id] => 10
[name] => Login
[text] => Login
[href] => ,
[parent_id] => 5
)
[10] => Array
(
[id] => 11
[name] => PHP Resources
[text] => Resources
[href] => ,
[parent_id] => 3
)
);
变量中?