-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetSession.php
More file actions
48 lines (45 loc) · 926 Bytes
/
Copy pathsetSession.php
File metadata and controls
48 lines (45 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
session_start();
//Array of all songs to be possibly loaded
$songs = array(
'e' => array(
'007607b_',
'018506b_',
'028300b_',
'037300b_',
'040900bv',
'066000b_',
),
'b' => array(
'bach-138',
'bach-207',
'bach-272',
'bach-329',
'bach-380',
'bach-470',
),
);
function randNum($min, $max, $quantity) {
$numbers = range($min, $max);
shuffle($numbers);
return array_slice($numbers, 0, $quantity);
}
function setSession($songs) {
$eCount = rand(4,6);
$bCount = 10 - $eCount;
$eValues = randNum(0, sizeof($songs['e']) - 1, $eCount);
$bValues = randNum(0, sizeof($songs['b']) - 1, $bCount);
$values = array();
$i = 0;
foreach($eValues as $key) {
$values[$i] = array($songs['e'][$key], 'e');
$i++;
}
foreach($bValues as $key) {
$values[$i] = array($songs['b'][$key], 'b');
$i++;
}
shuffle($values);
$_SESSION['data'] = $values;
}
?>