I was working OpenCart and added such code to Controller to show all the manufacturers to User:
$this->load->model("catalog/manufacturer");
$manufacturers = $this->model_catalog_manufacturer->getManufacturers();
$allbrands = array();
foreach ($manufacturers as $brand)
{
$brand["url"] = $this->url->link("product/manufacturer/product&manufacturer_id=".(string) $brand["manufacturer_id"],"","SSL");
$allbrands[] = $brand;
}
$this->data["manufacturers"] = $allbrands;
It worked just fine but my previous code didn't work which is below:
$this->load->model("catalog/manufacturer");
$manufacturers = $this->model_catalog_manufacturer->getManufacturers();
$allbrands = array();
foreach ($manufacturers as $brand)
{
$brand["url"] = $this->url->link("product/manufacturer/product&manufacturer_id=".(string) $brand["manufacturer_id"],"","SSL");
}
$this->data["manufacturers"] = $manufactures;
What I was thinking is arrays are objects so they are pointed at references so if I change $brand variable then $manufacturers will also have arrays that have "url" as index but didn't work and PHP complains that it doesn't have any "url" index.
Assigning a new index to an array cause it to be recreated with new object in the heap or it extends the current object's place in the heap?
Any ideas, what might it happen?