How to organize matrix

-1

A comparison is being made:

This is so

$result3 = array_diff($fetchForm, $items['form_id']);
print_r($result3);

    Array
    (
        [0] => 1
        [2] => 3
    )

$result2 = array_diff($items['form_id'], $fetchForm);
print_r($result2);

    Array
    (
        [1] => 4
    )

so

Array
(
    [0] => 1
    [1] => 3
)

Array
(
    [0] => 4
)
    
asked by anonymous 15.09.2014 / 23:52

1 answer

2
  

Array-diff , returns an array containing all array1 entries that are not present in any of the other arrays.

Array-diff will return KEY and VALUE, so you do not get an array with ordered indexes.

$array1 = array("verde", "vermelho", "azul", "amarelo");
$array2 = array("verde", "vermelho");
$result = array_diff($array1, $array2);

output : array( 2 => 'azul' , 3 => 'amarelo' )

To redo your array in order, you can use array_values

$result = array_values( $result );
print_r($result);

output : array( 0 => 'azul' , 1 => 'amarelo' )

    
16.09.2014 / 00:19