Hello all.
Just like to seek your opinion about how I should store 300+ program settings that I would be using for the rest of the program. I would have to read all of them at once at the start.
So far I was thinking of either:
- Store them in aaa.php and read the variables from the file. Eg:
include "aaa.php";
aaa.php
<?
$c['red'] = 'apple';
$c['green'] = 'pear';
$c['orange'] = 'orange';
.
.
. 300+ times;
?>
// Such that print_r($c) displays:
Array
(
'red' => 'apple'
'green' => 'pear'
'orange' = > 'orange'
.
.
.
. 300+ times
)
------------- or --------------
- Keep them in a table called 'vars' in mysql with two fields to store the $key and the corresponding $value. Doing so, I would have to run the code below.
Example:
$a = array ();
$b = array ();
from 'vars' in mysql ==>..... $a == $key ... $b == $value
// At this point in time,
$a = array('red','green','orange'.......);
$b = array('apple','pear','orange'.........);
then I do this:
$c = array_flip ($a);
foreach ($c as $v) { $c["$a[$v]"] = $b[$v];}
// such that print_r($c) displays:
Array
(
'red' => 'apple'
'green' => 'pear'
'orange' = > 'orange'
.
.
.
. 300+ times
)
Would using "mysql + the code" be faster than reading directly from a file "aaa.php"? Could anyone advise me on a more efficient method of getting my variables before proceeding on with running the rest of the script?
Thanks a million!