read from .info files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shv_rk
Forum Newbie
Posts: 2
Joined: Fri Nov 19, 2010 6:26 am
Location: London

read from .info files

Post by shv_rk »

Hi,

First of junior php developer i need some guiding or code examples for:

I have created a file sample.info and I need to extract string/information from it.
my info file is looks like drupal or wordpress cms:

name = test
description = this is a test file
author = shv
version = 1.0
core = 6.x
engine = phptemplate

screenshot = native.png

stylesheets[all][] = css/style.css
stylesheets[if IE 7][] = css/style-IE7.css
stylesheets[if IE 8][] = css/style-IE8.css

scripts[] = js/example.js

I want to create a function to print out all CSS files path for example.

please give me some guidings.

regards
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: read from .info files

Post by califdon »

I'm not sure just what information you need. First, if you aren't already familiar with it, you need to know how to read a text file, storing the lines into variables so you can work with them. If you are not already familiar with this, check the manual to learn how to use file(), fgets(), fopen(), fread(), fclose(), file_get_contents(), etc. Each of these PHP functions may be useful in reading the contents of a text file into an array or strings. When you have the contents of your .info file in an array, for example, you can use a loop structure to search for specific content that you are interested in, then process the content however you need to.

Use Google to quickly find specific information on whatever PHP function you are interested in. For example, to learn how to use the file() function, search Google for php file().
s992
Forum Contributor
Posts: 124
Joined: Wed Oct 27, 2010 3:06 pm

Re: read from .info files

Post by s992 »

Just adding a little onto califdon's post...the PHP.net manual is great for learning about the functions too.

To search for a specific function, you can just visit http://www.php.net/functionname. For example, http://www.php.net/file will bring you to the manual page for the file() function.
shv_rk
Forum Newbie
Posts: 2
Joined: Fri Nov 19, 2010 6:26 am
Location: London

Re: read from .info files

Post by shv_rk »

thank you very much
Post Reply