Page 1 of 1

read from .info files

Posted: Fri Nov 19, 2010 6:46 am
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

Re: read from .info files

Posted: Fri Nov 19, 2010 4:09 pm
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().

Re: read from .info files

Posted: Fri Nov 19, 2010 4:13 pm
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.

Re: read from .info files

Posted: Wed Mar 09, 2011 8:58 am
by shv_rk
thank you very much