Jak pobrać samo id oraz Text z pliku txt?

0

Witam, w jaki sposób mogę pobrać z pliku liczby przed tabem oraz sam text po tabie?

mój kod.php


header('Content-type: text/html; charset=Windows-1256');


$handle = fopen('test.txt', 'r');

$array = [];


if ($handle) {
    while (($line = fgets($handle)) !== false) {
       $ID = (int) filter_var($line, FILTER_SANITIZE_NUMBER_INT);
       $array[$ID] = $line;

	print_r($array);
    }


  //  print_r($array);
    fclose($handle);
} 

test.txt

1 [tab]tutaj jest jakis text
3 [tab]tutaj kolejny text
2 [tab]tutaj kolejny text

program ma pobierać id = te liczby oraz po tabie sam text

0

http://php.net/manual/en/function.fgetcsv.php

if (($handle = fopen("test.txt", "r")) !== FALSE) {
 while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE) {
        print_r($data);
    }
    fclose($handle);
}

1 użytkowników online, w tym zalogowanych: 0, gości: 1