public function LdapTestFunctions::parseCsv in Lightweight Directory Access Protocol (LDAP) 7.2
Same name and namespace in other branches
- 8.2 ldap_test/LdapTestFunctions.class.php \LdapTestFunctions::parseCsv()
1 call to LdapTestFunctions::parseCsv()
File
- ldap_test/
LdapTestFunctions.class.php, line 416
Class
Code
public function parseCsv($filepath) {
$row = 1;
$table = [];
if (($handle = fopen($filepath, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if (count($data) > 1) {
$table[] = $data;
}
}
fclose($handle);
}
$table_associative = [];
$headings = array_shift($table);
foreach ($table as $i => $row) {
$row_id = $row[0];
foreach ($row as $j => $item) {
$table_associative[$row_id][$headings[$j]] = $item;
}
}
return $table_associative;
}