排序多维数组使用PHP的CSV数据建 [英] Sort multi-dimensional array built from CSV data using PHP

查看:164
本文介绍了排序多维数组使用PHP的CSV数据建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图排序在正在从CSV填充的PHP的阵列。我也,理想,爱情可以通过点击选项卡中的表这里控制排序..右不过现在,我手头的第一项任务是刚刚整理该死的东西..这方面的工作超过3天了..任何帮助是极大的AP preciated!干杯!

PHP

 < PHP$计划生育= fopen(\"https://s$p$padsheets.google.com/pub?key=0AjZgwY03sLMGdHVoWjhucGowWWJBb2g2NnQzVG9HZFE&hl=en&single=true&gid=0&output=csv\",\"r\");
$行=阵列();
而(($行= fgetcsv($ FP))!== FALSE){
    $行[] = $行;
}
FCLOSE($ FP);$头= array_shift($行);
的foreach($行作为$行):列表($ ShowKey,$ ShowFeedURL,$ ShowLink,$ ShowIcon,$ ShowTitle,$ ShowTag,$ ShowCategory,$ ShowEps,$ ShowLastUpdate,$ ShowNew)= $行;$ oddpost =(空($ oddpost))? _odd':''; ?>


解决方案

而不是在PHP排序表,你可以考虑做客户端的Javascript。比如看看这个jQuery插件: http://tablesorter.com/

Trying to sort an array in PHP that is being populated from a CSV. I would also, ideally, LOVE to be able to control the sort by clicking on tabs in the table here .. Right now, though, my first task at hand is just sorting the damn thing.. been working on this for over 3 days now.. any help is GREATLY appreciated!! Cheers!

PHP

<?php 

$fp = fopen("https://spreadsheets.google.com/pub?key=0AjZgwY03sLMGdHVoWjhucGowWWJBb2g2NnQzVG9HZFE&hl=en&single=true&gid=0&output=csv","r"); 
$rows = array(); 
while (($row = fgetcsv($fp)) !== FALSE) { 
    $rows[] = $row; 
}
fclose($fp); 

$headers = array_shift($rows);
foreach ($rows as $row) : list($ShowKey, $ShowFeedURL, $ShowLink, $ShowIcon, $ShowTitle, $ShowTag, $ShowCategory, $ShowEps, $ShowLastUpdate, $ShowNew) = $row;

$oddpost = ( empty( $oddpost ) ) ? '_odd' : ''; ?>

解决方案

Instead of sorting the table in PHP, you may consider doing it client-side in Javascript. For instance have a look at this jQuery plugin: http://tablesorter.com/

这篇关于排序多维数组使用PHP的CSV数据建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆