learning, task4/6
4 -> not working 5,6 -> not done yet
This commit is contained in:
46
lernen/ka-1-lbt3+4/aufgabe4.php
Normal file
46
lernen/ka-1-lbt3+4/aufgabe4.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
// ###########
|
||||
// # WICHTIG #
|
||||
// ###########
|
||||
// geht nicht!
|
||||
|
||||
// Datei
|
||||
$file = "produkt.csv";
|
||||
|
||||
if(!file_exists($file)){
|
||||
die("File $file doesn't exist or not found!");
|
||||
// Beende das Skript
|
||||
}
|
||||
|
||||
$fp = @fopen($file, 'r'); // a -> all (read, write ...)
|
||||
if(!$fp){
|
||||
die("Error while opening file!");
|
||||
}
|
||||
|
||||
$header = fgetcsv($fp, 0, ",");
|
||||
|
||||
fclose($fp);
|
||||
|
||||
// READ FILE
|
||||
|
||||
$fp = @fopen($file, "W");
|
||||
|
||||
$yo = print_r($header);
|
||||
echo "<pre> $yo </pre>";
|
||||
|
||||
while(!feof($fp)){ // solange nicht das Ende der Datei erreicht ist
|
||||
|
||||
// Inner Schleife: Spalten ausgeben
|
||||
for ($i = 0; $i < count($header); $i++){
|
||||
echo "$header[$i]: $header[$i]<br>";
|
||||
}
|
||||
echo "<p> -------------------------------- </p>";
|
||||
}
|
||||
|
||||
// WRITE TO FILE
|
||||
|
||||
//$row = [7, "NZXTKeyboard", 120, "Tastatur"];
|
||||
// file, data (array), seperator
|
||||
//fputcsv($fp, $row, ",");
|
||||
|
||||
Reference in New Issue
Block a user