How transform a php array in a php array with no index?

I already saw old questions here on stackoverflow but i have no success.

i´m trying to use a foreach as this:

$arr = [];
$id = '10';
    foreach($ext as $e){
        if(!empty($e)){
           $only_filled[] = array_merge($arr, ['img'+($pointer+1) => $id.'_'.$e]);
        }
    }

Result i got:

array (size=2)
     0 => 
        array (size=1)
            'img1' => string '10_1.jpg' (length=8)
     1 => 
        array (size=1)
            'img3' => string '10_3.jpg' (length=8)

Result i need:

array (size=2)
  'img1' => string '10_1.jpg' (length=8),
  'img3' => string '10_3.jpg' (length=8)`
728x90

1 Answers How transform a php array in a php array with no index?

You need an associative array and in your code, you are creating a simple array

Try code like this

foreach($ext as $e){
    if(!empty($e)){
       $only_filled['img'.($pointer+1)] = 'Your Value';
    }
}

4 months ago