Click here to Skip to main content
15,889,808 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to parse following type of formatted config file using PHP.
VB
config 'Environment' 'MyInfo'
    option 'Name' '0'
    option 'Mobile' '0'
    option 'EMAIL' '0'


if we use parse_ini_file() function then it would require ini file in specific format. Please suggest how to parse such files.

Regds
Posted

1 solution

You have to read the text file (you may find several approaches discussed in this page: "The right way to read files with PHP"[^] and then parse yourself the read content (useful info here: "PHP - parsing a txt file" at Stack Overflow[^].
 
Share this answer
 
Comments
SNI 11-Oct-13 4:29am    
Thanks for reply. I want to parse file after specified time interval so which option is better either file_get_contents to read the contents ot fopen the traditional way?
CPallini 11-Oct-13 4:33am    
In my opinion, it really depends on the file size. I would use, if possible, file_get_contents.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900