Code: Select all
$myvar[value_a] = array('title'=> 'Title of Value_a', 'description' => 'Description for Value_a');
$myvar[value_b] = array('title'=> 'Title of Value_b', 'description' => 'Description for Value_b');
$myvar[value_c] = array('title'=> 'Title of Value_c', 'description' => 'Description for Value_c');
$myvar[value_d] = array('title'=> 'Title of Value_d', 'description' => 'Description for Value_d');
$myvar[value_e] = array('title'=> 'Title of Value_e', 'description' => 'Description for Value_e');
$myvar[value_f] = array('title'=> 'Title of Value_f', 'description' => 'Description for Value_f');This is for a project where depending on what value the code calls for, it inserts the appropriate title and description. So my arrays need to keep the same variable ($myvar) for every line like listed above. Now this functions perfectly, but is not relevant to my question. I only mention it to mate not that I cannot use different varabile names for each line.
Okay, my question... In another page on the site I am wanting to have a list that will show all lines of the txt file. For example, it would appear like:
Title of Value_a Description for Value_a
Title of Value_b Description for Value_b
...and so on.
In my mind, I am thinking the code would be sometihng like this:
Code: Select all
$allarrays = "thearrayfile.txt";
$lines = file($allarrays);
foreach ($lines as $line)
{
echo ($myvar[]['title'].$myvar[]['description'].'<br />');
}Would someone more knowledgeable of PHP be able to see a quick fix to this solution? If you need further info, let me know, and thanks in advance.