How do I parse a .pls file using PHP? Having trouble with parse_ini_file
parsing, php
Solution
Try using the `INI_SCANNER_RAW` scanner, something like this:
parse_ini_file('playlist.ini', true, INI_SCANNER_RAW);
This should handle strings with spaces and `[]`s without `"` around them better. See scanner modes at the `parse_ini_file()`'s manual.
Problem
I have this file: ``` [playlist] numberofentries=4 File1=http://108.61.73.119:8128 Title1=(#1 - 266/1000) 181.FM - POWER 181 -=[: The Hitz Channel :]=- www.181.fm Length1=-1 File2=http://108.61.73.118:8128 Title2=(#2 - 318/1000) 181.FM - POWER 181 -=[: The Hitz Channel :]=- www.181.fm Length2=-1 File3=http://108.61.73.117:8128 Title3=(#3 - 401/1000) 181.FM - POWER 181 -=[: The Hitz Channel :]=- www.181.fm Length3=-1 File4=http://198.27.79.224:9770 Title4=(#4 - 27/50) 181.FM - POWER 181 -=[: The Hitz Channel :]=- www.181.fm Length4=-1 Version=2 ``` I'd like to parse it and get only file and title. Problem is parse_ini_file gives me bogus error. I tried normal way, like I would parse text file but it is becoming complicated with too much trimming. Any thoughts? php: ``` $streams = parse_ini_file("tunein-station.pls", true); print_r($streams); ``` Error: ``` PHP Warning: parse error in tunein-station.pls on line 4\n ```