将基于查询的所有行提取到数组中并返回单个值
查询数据库
//----------------------------------------------------------------------
$result = mysql_query("SELECT * FROM $tableName"); query
$array = mysql_fetch_row($result);
在数组中获取结果
$arr = array();
while ($row = mysql_fetch_assoc($result)) {
$arr2 = array();
foreach ($row as $val) $arr2[] = $val;
$arr[] = $arr2;
}
结果将
Array
(
[0] => Array
(
[0] => status_site
[1] => 0
)
[1] => Array
(
[0] => title_site
[1] => Script
)
[2] => Array
(
[0] => keys_site
[1] =>
)
)
我需要创建返回元素0到1的函数
ex: function getsetting (title_site){
return value script}
答案 0 :(得分:1)
将$arr[] = $arr2;
替换为$arr[$arr2[0]] = $arr2[1];
。这可能会解决您的问题。