Alex
Alex

Reputation: 68440

Change values from a array while iterating

the array:

('abc', 'def', 'xyz')

foreach($arr as $item)
  // change $item here

Can I do this without creating a intermediate array?

Upvotes: 3

Views: 892

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798576

Use a reference.

foreach($arr as &$item)

Upvotes: 10

Related Questions