Ciao ragazzi, devo fare un sistema di import da file txt il cui contenuto è così:
codice:
301    301                        2 Pac Ft. The Notorious B.I.G.                   Running          
398    398                        50 Cent                                          Wanksta          
2      002                        50 Cent                                          21 Questions     
271    271                        50 Cent                                          P.I.M.P          
278    278                        A Teens                                          Perfect Match    
114    114                        A Teens                                          Floor Filler     
395    395                        Ace Of Base                                      Unspeakable      
83     083                        Afroman                                          Crazy Rap        
119    119                        A-HA                                             Forever Not Yours
Questo è il Php:
Codice PHP:
$file file_get_contents("Lista.txt");
$righe explode("\n",$file);
echo 
Count($righe)."
"
;

$i 0;
foreach(
$righe as $r) {

  
$cod trim(substr($r,10,20));
  
$art trim(substr($r,46,120));
  
$tit trim(substr($r,165,82));

  echo 
"$cod | $art | $tit \n
"
;

Praticamente devo pescare la seconda fila di numeri, l'artista e il titolo che poi inserirò in un database...
Il php da dei problemi in substr($r....)
Penso che dipenda dal file txt che sembra essere formattato bene.. ma quando lo importo il risultato è questo:
codice:
3 0 1 | 2   P a c   F t .   T h e   N o t o r i o u s   B . I . G . | R u n n i n g 

3 9 8 | 5 0   C e n t | W a n k s t a 

0 0 2 | 5 0   C e n t | 2 1   Q u e s t i o n s 

2 7 1 | 5 0   C e n t | P . I . M . P 

2 7 8 | A   T e e n s | P e r f e c t   M a t c h 

1 1 4 | A   T e e n s | F l o o r   F i l l e r 

3 9 5 | A c e   O f   B a s e | U n s p e a k a b l e 

0 8 3 | A f r o m a n | C r a z y   R a p 

1 1 9 | A - H A | F o r e v e r   N o t   Y o u r s
non capisco da dove vengano questi spazi.. :master: