- 论坛徽章:
- 0
|
?php
/*示例
$conn=mssql_connect('127.0.0.1','sa','ybnews');
mssql_select_db('newsroom',$conn);
$sql="select * from test\";
$result=mssql_query($sql);
while ($rs=mssql_fetch_array($result)){
$row[]=$rs[1];
}
echo splitcol($row,'2');
*/
function splitcol($array,$colnum){//记录数组,列的数目
$i=1;
$col=" \n \n";
$code="\n \n";
$colnum=!$colnum?1:$colnum;
if (is_array($array)){
foreach ($array as $arr){
$code.=" ".$arr."\n";
$code.=$i % $colnum == 0?$col:'';
$i++;
}
}
$code.=" \n";
return $code;
}
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/33579/showart_259898.html |
|