Reputation: 251
I have an array which is like this :
foreach($keys as $tmpItem) {
$item = null;
$item['id'] = $tmpItem;
$item['price'] = $prices[$tmpItem];
$items[] = $item;
}
I want to add + 10 for each item in my array.
Item[0] = 10,
Item[1] = 20,
item[2] = 30
etc...
How can i do it ? Thanks
Upvotes: 0
Views: 34
Reputation: 7426
You could just do this:
$i=0;
foreach($keys as $tmpItem) {
$i+=10;
$item = null;
$item['id'] = $tmpItem;
$item['price'] = $prices[$tmpItem];
$items[] = $i;
}
Upvotes: 1
Reputation: 337
You need this?
$aux=0;
foreach($keys as $tmpItem) {
$aux = $aux+10;
$item = null;
$item['id'] = $tmpItem;
$item['price'] = $prices[$tmpItem];
$items[] = $aux;
}
Upvotes: 1