Jump to content

[SOLVED] Help: reading a m3u file


clown[NOR]

Recommended Posts

well, as the subject sais I'm trying to read a .m3u file.. I'm almost done but got one problem.. I'm trying to remove every non related info for the song info.. meaning the #EXTINF: etc... I've managed to strip the #EXTINF but the problem comes to removing the number after that...

 

the code I've got now is:

<?php

$file = file("test.m3u");
foreach ($file as $linje) {
	if (substr($linje, 0, 7) == "#EXTINF") {
		# echo $linje."<br>";
		$info = explode(",", $linje);
		echo $info[1]."<br>";
	}
}

?>

 

this is how it looks without using the if statement:

#EXTINF:220,Brainstormers - Tre Nyanser Av Sorg

#EXTINF:238,Barinstormers - He-Man

#EXTINF:202,Brainstormers - A New Day

#EXTINF:159,Chemiste - Get Burned

#EXTINF:256,Chemiste - Tha Bomb

#EXTINF:202,Damien - Penger, Hat & Fitte

#EXTINF:274,Dekar & Keem One - Ja Vi Elsker

#EXTINF:297,Dekar - Rainy Days (Mista Visa SoulBrother Remix)

#EXTINF:191,Endre Modus - Loony Toon (feat. Palabras)

#EXTINF:277,Floppydisk & Karlkrackhead - You is bitch

#EXTINF:173,Floppydisk - Daydreaming

#EXTINF:133,Grim Fandango - Dø Ditt Svin

#EXTINF:171,Keem One - 4 Tha Ladies

#EXTINF:272,Keem One - 9mm

#EXTINF:245,Keem One - Det Er Meg!

#EXTINF:86,Keem One - Fuck You!

#EXTINF:225,Keem One - Hvem Er Han?

#EXTINF:221,Keem One - Spytt På Suleiman

#EXTINF:237,ikke spre - cypher

#EXTINF:294,Keem One & Dekar - Troru Ikke Vi Driter I Det?

#EXTINF:241,Keem, Chemmy & The Brainstormers - 16x5

#EXTINF:170,Keem One & Chemiste - Kanke Du Bare Dø!?

#EXTINF:181,Ordrett - Hvor Dust Gåre Egentlig Ann Å Bli?

#EXTINF:166,Ordrett & Thorin - 2 Språk, 2 Karer

#EXTINF:159,Patrick Bateman - Bumlife

#EXTINF:117,Rhyme Jaw & Roma - Rhyme Jaw

#EXTINF:127,Roma - 6 Fot Dyp

#EXTINF:119,Roma - Fuck Suleiman

#EXTINF:124,Roma - Lille Markus

#EXTINF:227,Roma - Rim Du Aldri Glemmer

#EXTINF:265,Roma - Politikerne Vil Aldri Forstå

#EXTINF:241,SantiEgo - Drikking

#EXTINF:217,Skyggen - Tidens Sorg

#EXTINF:220,Spooks - Don't Sleep

#EXTINF:151,Onkl P & Jaa9 - Stank Ass Ho

#EXTINF:175,The Chemiste & Munajj - So What (feat. Soul Theory)

#EXTINF:245,Chemiste - C.H.E.M.I.S.T.E

#EXTINF:176,Tvist - Fuck Alle Hatere

#EXTINF:170,Tvist - Dø (feat. Anette)

#EXTINF:211,Tvist - Pinlig (feat. Keem One)

#EXTINF:227,Vannskapt Mannskap - Har'ukke Lært

#EXTINF:292,Onkl P, Keem One, Jaa9 & Roma - Vi Liker Deg Ikke!!

 

this is how it looks with the if statement

Brainstormers - Tre Nyanser Av Sorg 
Barinstormers - He-Man 
Brainstormers - A New Day 
Chemiste - Get Burned 
Chemiste - Tha Bomb 
Damien - Penger
Dekar & Keem One - Ja Vi Elsker 
Dekar - Rainy Days (Mista Visa SoulBrother Remix) 
Endre Modus - Loony Toon (feat. Palabras) 
Floppydisk & Karlkrackhead - You is bitch 
Floppydisk - Daydreaming 
Grim Fandango - Dø Ditt Svin 
Keem One - 4 Tha Ladies 
Keem One - 9mm 
Keem One - Det Er Meg! 
Keem One - Fuck You! 
Keem One - Hvem Er Han? 
Keem One - Spytt På Suleiman 
ikke spre - cypher 
Keem One & Dekar - Troru Ikke Vi Driter I Det? 
Keem // This contained another comma
Keem One & Chemiste - Kanke Du Bare Dø!? 
Ordrett - Hvor Dust Gåre Egentlig Ann Å Bli? 
Ordrett & Thorin - 2 Språk
Patrick Bateman - Bumlife 
Rhyme Jaw & Roma - Rhyme Jaw 
Roma - 6 Fot Dyp 
Roma - Fuck Suleiman 
Roma - Lille Markus 
Roma - Rim Du Aldri Glemmer 
Roma - Politikerne Vil Aldri Forstå 
SantiEgo - Drikking 
Skyggen - Tidens Sorg 
Spooks - Don't Sleep 
Onkl P & Jaa9 - Stank Ass Ho 
The Chemiste & Munajj - So What (feat. Soul Theory) 
Chemiste - C.H.E.M.I.S.T.E 
Tvist - Fuck Alle Hatere 
Tvist - Dø (feat. Anette) 
Tvist - Pinlig (feat. Keem One) 
Vannskapt Mannskap - Har'ukke Lært 
Onkl P // This contained another comma
[code]

how can I only take away everything before the first comman, and show everything after?

Thanks In Advance
- Clown

[/code]

Link to comment
https://forums.phpfreaks.com/topic/50194-solved-help-reading-a-m3u-file/
Share on other sites

i know my post got a lil messed up :) what I need help to is to be able to read everything after the first part in the array..

 

let's say I have an array that goes like this

$array = array(0 => "Phone", 1 => "Hello", 2 => "world", 3 => "!");

 

i want to just skip 0 and read from 1 to 3... but in my case I'm not sure how many values there's gonna be in the array..

I had to do something similar - and here is what I did (I just changed it to match your purposes):

 

http://sandynpaul.com/test/m3utest.php

 

<?PHP
foreach(file("filename.m3u") as $file)
{
        preg_match('/^#EXTINF:[[:digit:]]+,(.*)$/',$file,$matches);
	//preg_match('/^.*$/',$file,$matches); This matches the entire line
	if ($matches) {
		echo $matches[1], '<br />';
	} else { //somethings wrong with either the file (is it empty?) or the regular expression
		echo 'ZOMGBEES!!!!!!!!!!!!!!!!!!!!!!!!!!';
	}

}
?>

 

output:

 

Brainstormers - Tre Nyanser Av Sorg
Barinstormers - He-Man
Brainstormers - A New Day
Chemiste - Get Burned
Chemiste - Tha Bomb
Damien - Penger, Hat & Fitte
Dekar & Keem One - Ja Vi Elsker
Dekar - Rainy Days (Mista Visa SoulBrother Remix)
Endre Modus - Loony Toon (feat. Palabras)
Floppydisk & Karlkrackhead - You is bitch
Floppydisk - Daydreaming
Grim Fandango - Dø Ditt Svin
Keem One - 4 Tha Ladies
Keem One - 9mm
Keem One - Det Er Meg!
Keem One - Fuck You!
Keem One - Hvem Er Han?
Keem One - Spytt På Suleiman
ikke spre - cypher
Keem One & Dekar - Troru Ikke Vi Driter I Det?
Keem, Chemmy & The Brainstormers - 16x5
Keem One & Chemiste - Kanke Du Bare Dø!?
Ordrett - Hvor Dust Gåre Egentlig Ann Å Bli?
Ordrett & Thorin - 2 Språk, 2 Karer
Patrick Bateman - Bumlife
Rhyme Jaw & Roma - Rhyme Jaw
Roma - 6 Fot Dyp
Roma - Fuck Suleiman
Roma - Lille Markus
Roma - Rim Du Aldri Glemmer
Roma - Politikerne Vil Aldri Forstå
SantiEgo - Drikking
Skyggen - Tidens Sorg
Spooks - Don't Sleep
Onkl P & Jaa9 - Stank Ass Ho
The Chemiste & Munajj - So What (feat. Soul Theory)
Chemiste - C.H.E.M.I.S.T.E
Tvist - Fuck Alle Hatere
Tvist - Dø (feat. Anette)
Tvist - Pinlig (feat. Keem One)
Vannskapt Mannskap - Har'ukke Lært
Onkl P, Keem One, Jaa9 & Roma - Vi Liker Deg Ikke!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.