update page now
Longhorn PHP 2026 - Call For Papers

Voting

: four minus zero?
(Example: nine)

The Note You're Voting On

b4301775 at klzlk dot com
14 years ago
Quick example for using array_udiff to do a multi-dimensional diff

Returns values of $arr1 that are not in $arr2

<?php
$arr1 = array( array('Bob', 42), array('Phil', 37), array('Frank', 39) );
        
$arr2 = array( array('Phil', 37), array('Mark', 45) );
        
$arr3 = array_udiff($arr1, $arr2, create_function(
    '$a,$b',
    'return strcmp( implode("", $a), implode("", $b) ); ')
    );
        
print_r($arr3);
?>

Output:

Array
(
    [0] => Array
        (
            [0] => Bob
            [1] => 42
        )
 
    [2] => Array
        (
            [0] => Frank
            [1] => 39
        )
 
)
1

Hope this helps someone

<< Back to user notes page

To Top