-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcsv.php
More file actions
73 lines (63 loc) · 1.6 KB
/
csv.php
File metadata and controls
73 lines (63 loc) · 1.6 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!doctype HTML>
<html>
<head>
<meta charset="UTF-8" />
<meta name="description" content="" />
<title>CSV</title>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/dark-hive/jquery-ui.css"/>
<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"/>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.0.3.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$(document).ready(function(){
});
</script>
</head>
<!-- PHP DECLARE FUNCTIONS AND VARIABLES -->
<?php
function open_csv($string_location)
{
ini_set('auto_detect_line_endings', true);
if (($handle = fopen($string_location, "r+")) !== false)
{
while (($data = fgetcsv($handle, ",")) !== false)
{
$length = count($data);
for ($index=0; $index < $length; $index++)
{
$array[] = $data[$index];
}
}
}
return $array;
}
function format_csv($array)
{
$array_len = count($array);
for ($index = 12; $index < $array_len; $index += 12)
{
// Declare variables
$count = 0;
$record_number = $index / 12;
echo "<h1>Record " . $record_number . "</h1><ul>";
// Retrieve next entry
while ($count != 11)
{
echo "<li>" . $array[$count] . ": " .
$array[$index + $count] . "</li>";
$count++;
}
echo "</ul>";
}
}
?>
<!-- END OF PHP DECLARATIONS -->
<body>
<div class="container">
<?php
$csv_array = open_csv("us-500.csv");
format_csv($csv_array);
?>
</div> <!--End of #container -->
</body>
</html>