I have this piece of code :
$start = ['23','', 'what'];
foreach($start as $i){
if($i ==''){
$i = 'satisfaction';
}
}
print_r($start);
The output is :
Array
(
[0] => 23
[1] =>
[2] => what
)
Why did index [1] not get replaced with 'satisfaction'. In other words : I don't want to create a new array, but change the index of an existing array. Actually, what I'm trying to achieve is to do intval()
on those indexes that are not empty (since intval on an empty index returns 0, which is not what I want).