How do I declare a variable with part of another variable plus some text at the end like this but without the syntax error...
$filename = $foreachvar['base_var']'.jpg';
You need the string concatenation operator:
$filename = $foreachvar['base_var'] . '.jpg';
^---
or, in a different way:
$filename = "{$foreachvar['base_var']}.jpg";
Using the concatenation operator:
$filename = $foreachvar['base_var'] . '.jpg';
You can also use the curly syntax:
$filename = "{$foreachvar['bae_var']}.jpg";
$filename = $foreachvar['base_var'] . '.jpg';
That's just assigning a value to the variable, which looks like what you're trying to do.