Decrease a multidimensional array

-1

Good night, I have a dilemma, I have tried in many ways but my knowledge with array is still vague, I would like help in the following, I have two arrays, one of them I already solved with a foreach because it was a simple array like this like this model

$data_content = Array
    (
        0 => null,
        1 => 'Fye Flourigh',
        2 => '+5521888',
        3 => null,
        4 => null,
        5 => null,
        6 => null
    );

But the second array is pretty weird, I need to make this array2

Array
(
    [0] => Array
        (
            [COLUMN_COMMENT] => 
            [0] => 
        )

    [1] => Array
        (
            [COLUMN_COMMENT] => Nome do contato
            [0] => Nome do contato
        )

    [2] => Array
        (
            [COLUMN_COMMENT] => Whatsapp
            [0] => Whatsapp
        )

    [3] => Array
        (
            [COLUMN_COMMENT] => Email
            [0] => Email
        )

    [4] => Array
        (
            [COLUMN_COMMENT] => Site
            [0] => Site
        )

    [5] => Array
        (
            [COLUMN_COMMENT] => Facebook
            [0] => Facebook
        )

    [6] => Array
        (
            [COLUMN_COMMENT] => Messenger
            [0] => Messenger
        )

)

is the same as array 1 so I can use

Follow two links to try to understand. this link 1 shows how you should stay link

and this link 2 shows how you are link

    
asked by anonymous 26.04.2016 / 01:59

1 answer

1

You should do the same thing you did before, but only by capturing what you want, in this case $ array [0] within a loop, or not.

Apparently you already have knowledge about for , so I'll use it.

// Sua array:
$array = array(
    array
        (
            'COLUMN_COMMENT' => '',
            '0' => ''
        ),
    array
        (
            'COLUMN_COMMENT' => 'Nome do contato',
            '0' => 'Nome do contato'
        ),
    array
        (
            'COLUMN_COMMENT' => 'Whatsapp',
            '0' => 'Whatsapp'
        ),
    array
        (
            'COLUMN_COMMENT' => 'Email',
            '0' => 'Email'
        ),
    array
        (
            'COLUMN_COMMENT' => 'Site',
            '0' => 'Site'
        ),
    array
        (
            'COLUMN_COMMENT' => 'Facebook',
            '0' => 'Facebook'
        ),
    array
        (
            'COLUMN_COMMENT' => 'Messenger',
            '0' => 'Messenger'
        )
);

$contagemArray = count($array);
// Quantidade de array existentes : 7

for($idArray=0; $idArray < $contagemArray; $idArray++) { 

  $atualArray = $array[$idArray];  
  // Array selecionada (0, 1, 2, 3)...

  $data_content[] = $atualArray[0];
  // Seleciona o valor "0" da array selecionada anteriormente. 

}

The $ data_content will contain:

array(7) {
  [0]=>
  string(0) ""
  [1]=>
  string(15) "Nome do contato"
  [2]=>
  string(8) "Whatsapp"
  [3]=>
  string(5) "Email"
  [4]=>
  string(4) "Site"
  [5]=>
  string(8) "Facebook"
  [6]=>
  string(9) "Messenger"
}
    
26.04.2016 / 03:25