array_keys($array) //返回所有键名
array_values($array) //返回所有键值
$result=array_reverse($input); //将数组颠倒,不保留键名
$result_keyed=array_reverse($input,true); //将数组颠倒,保留键名
array_keys($array,"blue"); //返回值为blue的键名
php导出excel
$filename="info.xls";//佅~H孾Z举I䷾@个excel彖~G件 header("Content-Type: application/vnd.ms-execl"); header("Content-Type: application/vnd.ms-excel; charset=utf-8"); header("Content-Disposition: attachment; filename=$filename"); header("Pragma: no-cache"); header("Expires: 0"); #excel列名 echo iconv("utf-8", "gb2312", "绾V住·")."\t"; echo iconv("utf-8", "gb2312", "妾S佐~M")."\t"; echo iconv("utf-8", "gb2312", "年齾D")."\t"; #连接数据库导出数据 $conn = mysql_connect("127.0.0.1","hello","hello"); mysql_select_db("machine"); $sql="select ip,business,service from machine_list"; $result=mysql_query($sql); while($row =mysql_fetch_array($result)){ echo "\n"; echo iconv("utf-8", "gb2312", $row['ip'])."\t"; echo iconv("utf-8", "gb2312", $row['business'])."\t"; echo iconv("utf-8", "gb2312", $row['service'])."\t"; }