1) Ich habe eine Textdatei (converted.txt), und dass Informationen Inhalt Benutzer:Wie konvertiert man Textdatei in Array in PHP?
0 hbhenet pppoe D4:CA:6D:F1:5D:5A 10.23.0.254 8h1m36s
1 R [email protected] pppoe 00:27:22:16:3B:F2 10.17.0.253 8h1m36s
2 R [email protected] pppoe 68:72:51:3A:53:1B 10.17.0.251 8h1m36s
3 R [email protected] pppoe 24:A4:3C:9F:83:10 10.17.0.252 8h1m36s
4 R [email protected] pppoe 24:A4:3C:E6:DD:3E 10.17.0.250 8h1m36s
5 R [email protected] pppoe 44:D9:E7:DA:32:95 10.16.0.246 8h1m36s
2) und was ich in meinem php getan haben, ist:
$file="converted.txt";
$fopen = fopen($file, "r");
$fread = fread($fopen,filesize($file));
fclose($fopen);
$remove = "\n";
$split = explode($remove, $fread);
$array[] = NULL;
$tab = "\t";
foreach ($split as $string)
{
$row = explode($tab, $string);
array_push($array,$row);
}
echo "<pre>";
print_r($array);
echo "</pre>";
3) die Ausgabe ist, wie:
Array
(
[0] =>
[1] => Array
(
[0] => 0 hbhenet pppoe D4:CA:6D:F1:5D:5A 10.23.0.254 8h1m36s
)
[2] => Array
(
[0] => 1 R [email protected] pppoe 00:27:22:16:3B:F2 10.17.0.253 8h1m36s
)
[3] => Array
(
[0] => 2 R [email protected] pppoe 68:72:51:3A:53:1B 10.17.0.251 8h1m36s
)
[4] => Array
(
[0] => 3 R [email protected] pppoe 24:A4:3C:9F:83:10 10.17.0.252 8h1m36s
)
[5] => Array
(
[0] => 4 R [email protected] pppoe 24:A4:3C:E6:DD:3E 10.17.0.250 8h1m36s
)
[6] => Array
(
[0] => 5 R [email protected] pppoe 44:D9:E7:DA:32:95 10.16.0.246 8h1m36s
)
)
4) aber was ich will, ist:
Array (
[0] => Array
(
[0] => Array
(
[0] => 0
[1] =>
[2] => hbhenet
[3] => pppoe
[4] => D4:CA:6D:F1:5D:5A
[5] => 10.23.0.254
[6] => 8h1m36s
)
[1] => Array
(
[0] => 1
[1] => R
[2] => [email protected]
[3] => pppoe
[4] => 00:27:22:16:3B:F2
[5] => 10.17.0.253
[6] => 8h1m36s
)
[2] => Array
(
[0] => 2
[1] => R
[2] => [email protected]
[3] => pppoe
[4] => 68:72:51:3A:53:1B
[5] => 10.17.0.251
[6] => 8h1m36s
)
[3] => Array
(
[0] => 3
[1] => R
[2] => [email protected]
[3] => pppoe
[4] => 24:A4:3C:9F:83:10
[5] => 10.17.0.252
[6] => 8h1m36s
)
[4] => Array
(
[0] => 4
[1] => R
[2] => [email protected]
[3] => pppoe
[4] => 24:A4:3C:E6:DD:3E
[5] => 10.17.0.250
[6] => 8h1m36s
)
[5] => Array
(
[0] => 5
[1] => R
[2] => [email protected]
[3] => pppoe
[4] => 44:D9:E7:DA:32:95
[5] => 10.16.0.246
[6] => 8h1m36s
)
)
)
irgendeine Idee? danke im voraus.
vielen Dank @Anant –
gute Arbeit geleistet .. ich wirklich zu schätzen, was Sie haben erledigt. Nochmals vielen Dank @Anant –