You must use a & with foreach to use the variable itself and not a copy of the variable.
foreach($products as &$product) {
$product['image'] = 'http://localhost/website/uploads/' . $product['image'];
}
An other way is to use array_map:
function addpath($product){
$product['image'] = 'http://localhost/website/uploads/' . $product['image'];
return $product;
}
$products = array_map('addpath', $products);
Or array_walk:
function addpath(&$product) {
$product['image'] = 'http://localhost/website/uploads/' . $product['image'];
}
array_walk($products, 'addpath');
For your test array, the first way seems to be faster. With a huge array (70000 items) you obtain foreach<array_walk<array_map with foreach ~ 1.5x faster than the two others.