-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers.php
More file actions
50 lines (34 loc) · 841 Bytes
/
users.php
File metadata and controls
50 lines (34 loc) · 841 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
49
50
<?php
//$handle = fopen('users.csv', 'r');
//$users = fgetcsv($handle);
$row=1;
if(($handle = fopen('users.csv', 'r'))!==FALSE){
while(($record = fgetcsv($handle, 0, ','))!==FALSE){
if($row==1){
$keys=$record;
$row++;
}else{
$records[] = array_combine($keys, $record);
}
}
function makePrimaryKey($key_name='Username', $records){
foreach($records as $record){
$index_name = $record[$key_name];
unset($record[$key_name]);
$new_records[$index_name] = $record;
}
return($new_records);
}
}
$sorted_records = makePrimaryKey('Username', $records);
print_r($sorted_records);
/*if(in_array('BGreenes', $records[0])){
echo 'Found Binny!';
$username = $records[0]['Username'];
$password = $records[0]['Password'];
if($password !== )
}else {
echo 'Can\'t find Binyomin';
}*/
print_r($records);
?>