$array = array('lastname', 'email', 'phone');
How do I run foreach
for this array and write updated value to its place?
Like:
foreach ($array as $item) {
// do something
// replace old value of this item with a new one
}
Example:
foreach ($array as $item) {
if (item == 'lastname')
$item = 'firstname';
// replace current $item's value with a 'firstname'
}
Array should become:
$array = array('firstname', 'email', 'phone');