I have the following code in PHP where I declare my variables inside an array, what I am looking for is to make a loop where I can generate the configuration depending on the number of "apples" selected, where I have not been able to advance is in making the variable increase its number, that is to say that it goes according to $i PHP:
$_['appleNum'] = 5;
$_['appleBrand1'] = "a";
$_['appleState1'] = "aa";
$_['appleBrand2'] = "b";
$_['appleState2'] = "bb";
$_['appleBrand3'] = "c";
$_['appleState3'] = "cc";
$_['appleBrand4'] = "d";
$_['appleState4'] = "dd";
$_['appleBrand5'] = "e";
$_['appleState5'] = "ee";
for ($i = 1; $i <= $_['appleNum']; $i++) {
$_['appleConfig'] = "edit APPLE" . $i . "
set brand " . $_['appleBrand#'] . "
set state " . $_['appleState#'] .;
}
For my taste you use a bit strange syntax to name variables. And you have not put well how that for is closed in your question.
Still, I think what you're looking for is this:
Which ends up returning this:
Surely you want it at the beginning of the line and split them in another way, but that was not what you were asking and I understand that you can fix it directly now that you have obtained an approximate output of what you expected to achieve, I think.