I made an array $brands inside class Cars, the print_r output looks like this:
Array ( [0] => Array (  [id] => 1 
                        [name] => 'Porsche'
                    ) 
        [1] => Array (  [id] => 2 
                        [name] => 'Bugatti'
                    ) 
        [2] => Array (  [id] => 3 
                        [name] => 'BMW'
                    ) 
    )
But when I'd like to link to a certain brand, I don't want to use strtolower() to make a lowercased hyperlink. I would like to echo $cars->brands[$i]['url'] (instead of strtolower($cars->brands[$i]['name'])).
class Cars {
So I needed to create a for loop, to create the ['url'] key in the array. I thought that a foreach would work:
foreach ($this->brands as $brand => $row) {
    $row['url'] = strtolower($row['name']);
}
But it didn't. Even this did not work: $row['name'] = strtolower($row['name']);.
But this worked, though:
for ($i = 0; $i < count($this->brands); $i++) { 
    $this->brands[$i]['url'] = strtolower($this->brands[$i]['name']);
}
}
My question here is: how? why?
 
     
     
    