<?php
$config_file = 'config.conf';
/* config file v0.2
php has a parse_ini function now, but this is still handy.. */
$array_from_file = file($config_file); foreach($array_from_file as $conf) {
// if first real character isn't '#', ';', or '[', and there is a '=' in the line.. if ( (substr(trim($conf),0,1) != '#') and (substr(trim($conf),0,1) != ';') and (substr(trim($conf),0,1) != '[') and (substr_count($conf,'=') >= 1) ) { $eq = strpos($conf, '='); $config[trim(substr($conf,0,$eq))] = trim(substr($conf, $eq+1)); } }
unset($array_from_file);
echo '<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1.0, width=device-width" /> </head><body> <div style=width:90%; margin-left: 20%"> The following configuration was pulled from <strong>',$config_file,'</strong> ..<br /> <pre>'; print_r($config); echo ' </pre>';
/* The config file :
############################# # this is a config file #
# i am a comment ; i am also a comment (for compatability with standard "ini" files)
var_name = setting
your variables are here: $conf['var_name'] = 'setting';
*/ ?>
|