我的阵列:
$horaire[] = array(
'Title' => 'Title_value',
'Day' => 'Day_value',
'Hour' => 'Hour_value',
'1erDiff' => 'yes'
);
我们说我有50个条目..(从EE频道条目中提取..) Day_value为0 - 6 如果Day的值是ex。:
,我想从这个数组创建新的数组$Sunday[] = array ('Title' => 'Title_value',
'Day' => 'Day_value', /**ALL VALUE HERE WILL BE 0 */
'Hour' => 'Hour_value',
'1erDiff' => 'yes');
$Monday[] = array ('Title' => 'Title_value',
'Day' => 'Day_value', /**ALL VALUE HERE WILL BE 1 */
'Hour' => 'Hour_value',
'1erDiff' => 'yes');
依旧......
OR
第二个问题 是否可以对第一个数组$ horaire进行排序,因为它从0-6(day_value)排序,但在此内部也排序hour_value(不更改Day_value排序..) 前,:
[0] = array (Day => 0, Hour => 5)
[1] = array (Day => 0, Hour => 9)
[2] = array (Day => 1, Hour => 3)
[3] = array (Day => 1, Hour => 10)
依旧......
例如:数据
Array (
[0] => Array ( [Nom] => Femmes entrepreneures [Jour] => 2 [Heure] => 18h30 [Min] => 30 [1erDiff] => oui )
[1] => Array ( [Nom] => Ma santé au quotidien [Jour] => [Heure] => [Min] => [1erDiff] => oui )
[2] => Array ( [Nom] => Noël j’magasine [Jour] => 2 [Heure] => 22h53 [Min] => 53 [1erDiff] => oui )
[3] => Array ( [Nom] => Noël j’magasine [Jour] => 1 [Heure] => 22h30 [Min] => 30 [1erDiff] => non )
[4] => Array ( [Nom] => Lancement de la programmation [Jour] => 2 [Heure] => 20h40 [Min] => 40 [1erDiff] => oui )
[5] => Array ( [Nom] => Voyages magazine [Jour] => [Heure] => [Min] => [1erDiff] => oui )
[6] => Array ( [Nom] => AMS Moto [Jour] => 4 [Heure] => 20h00 [Min] => 00 [1erDiff] => oui )
[7] => Array ( [Nom] => AMS Moto [Jour] => 4 [Heure] => 22h30 [Min] => 30 [1erDiff] => non )
[8] => Array ( [Nom] => AMS Moto [Jour] => 6 [Heure] => 05h00 [Min] => 00 [1erDiff] => non )
[9] => Array ( [Nom] => AMS VTT / Motoneige [Jour] => 3 [Heure] => 17h00 [Min] => 00 [1erDiff] => oui )
[10] => Array ( [Nom] => AMS VTT / Motoneige [Jour] => 3 [Heure] => 16h35 [Min] => 35 [1erDiff] => non )
[11] => Array ( [Nom] => AMS VTT / Motoneige [Jour] => 4 [Heure] => 19h28 [Min] => 28 [1erDiff] => non )
[12] => Array ( [Nom] => AMS VTT / Motoneige [Jour] => 5 [Heure] => 21h28 [Min] => 28 [1erDiff] => non )
[13] => Array ( [Nom] => AMS VTT / Motoneige [Jour] => 1 [Heure] => 05h28 [Min] => 28 [1erDiff] => non )
[14] => Array ( [Nom] => AMS VTT / Motoneige [Jour] => 4 [Heure] => 19h47 [Min] => 47 [1erDiff] => non )
[15] => Array ( [Nom] => Virage plus [Jour] => 3 [Heure] => 17h39 [Min] => 39 [1erDiff] => oui )
)
答案 0 :(得分:0)
第二部分:您可以定义自己的排序功能,按日和小时比较两个条目,然后使用该功能排序。
答案 1 :(得分:0)
要将值放入自己的数组中,您可以尝试这样的事情:
$days = array();
foreach ($horaire as $value) {
if (!isset($days[$value['Day']])) {
$days[$value['Day']] = array();
}
array_push($days[$value['Day']], $value);
}
然后在结束时你会有
$days[0] = all values where Day = 0
$days[1] = all values where Day = 1
...
$days[6] = all values where Day = 6