Hi @snychka, I am on the last step and also found some confusion regarding where to put the variable. The advice you gave podbarron makes sense, but I just want to make sure I fully understand it.
If we define the variable $difference with the arithmetic, $cities['dc'] - $year, at the top of the code like in pod's first code snippet, the $cities variable has no data and is null so the $difference variable does not get populated. Like you said, the variable $cities (with its multidimensional array) doesn't exist because it hasn't been created at that point.
When you say "at that point" do you say that because the compiler goes through lines of code from top to bottom 1-by-1? If compilers work the way I described, does the compiler arrive at the $difference variable before the $cities variable and return as NULL because its reference back to $cities contains nothing? I think that's how compilers work, but I may be wrong.
$year = 1774;
$cities = array(
'tokyo' => [
'dc' => [
'moscow' => [
'london' => [
$difference = $cities['dc'] - $year;
If I were to put the $difference variable right below the multidimensional array in the $cities variable, would that work too according to my deduction on how the compiler works? I'm just trying to understand by breaking it down as much as possible and step-by-step because the variable being thrown in line with the code threw me wayyy off. I don't think anywhere in the course it was mentioned that you could insert variables in line with your code. I mainly thought they should be at the top, although I see that I'm wrong about that.
Please feel free to correct me anywhere I'm wrong because I really want to understand. Also, if there was any point in the course that does say you can put variables there, could you point me to it? Or somewhere that explains this? I woulld really appreciate it. Thanks for your help and I hope you don't mind the wall of text!