I'm trying to create one long list of phrases by inserting each of the words in array $input into each of the strings in $base_list, for every value of $input.
Here's a simplified version of the code I'm using (and it does what I want it to):
$base_list = array("$input[$i] 1","$input[$i] 2","$input[$i] 3","$input[$i] 4","$input[$i] 5");
$size_base_list = count($base_list);
$input = array('a','b','c','d','e');
$size_input = count($input);
$output = array();
for ($i = 0; $i < $size_input; $i++)
{
for ($z = 0; $z < $size_base_list; $z++)
{
$base_list = array("$input[$i] 1","$input[$i] 2","$input[$i] 3","$input[$i] 4","$input[$i] 5");
$output[] = $base_list[$z];
}
}
$output = implode("<br>", $output);
print($output);
If I don't include the declaration of the $base_list array for the second time (inside the for($z...) loop), the code doesn't work and the value of $input[$i] is blank.
However, declaring the values for $base_list twice seems a bit redundant, and in my full version of the script I am using include() to call the $base_list array from a large external include file. The include inside the loop really slows things down, but if I don't use it, the script doesn't work.
Could someone please explain to me why the $base_list array has to be declared or included twice, and is there a faster or more efficient way of doing this?
Thanks in advance, sorry for the rambling post.