I feel like I'm struggling to find the answer here because I think I'm missing some key piece of info.
What I am trying to do is run a loop over some data, and then do something different with it based on one of it's values.
So the print_r of the data I am looping over gives me this. This is all good, it has only the data I need, nothing excess.
Array
(
[foodid] => 1
[menuid] => 1789798798
[creatorid] => 1
[foodtype] => hotdog
[frequency] => weekly
[cost] => 20
[chargedate] => 2017-07-14 11:05:18
)
And I want to do SOMETHING to it, depending on the value in frequency. The things I want to do are all stored in a set of identical arrays.
weekly, 2weekly, monthly, daily. eg
$_weekly = array(
"cost" => "2",
"order" => "5",
"years" => "0",
);
$_2weekly = array(
"cost" => "4",
"order" => "10",
"years" => "0",
);
Similar arrays for weekly 2weekly etc.
It seems simple to just use a var like $workingvar in the loop. So when I get there I can just use $workingvar = $_weekly, or $workingvar = $_2weekly.
So, how can I set the contents of $workingvar to be one of those existing arrays? Then I can use the same loop/function on each row in the data, and change the values it pulls in, depending on what that frequency value contains.
Edit added second array example.