note 105059 modified in function.array-diff by danbrown

From: Date: Mon, 25 Jul 2011 17:39:49 +0000
Subject: note 105059 modified in function.array-diff by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181862@lists.php.net to get a copy of this message
This is my simple function do compare two arrays. It adds the deleted values from the original array. <?php function array_diff_($old_array,$new_array) { foreach($new_array as $i=>$l){ if($old_array[$i] != $l){ $r[$i]=$l; } } //adding deleted values foreach($old_array as $i=>$l){ if(!$new_array[$i]){ $r[$i]=""; } } return $r; } ?> --was-- This is my simple function do compare two arrays. It adds the deleted values from the original array. function array_diff_($old_array,$new_array) { foreach($new_array as $i=>$l){ if($old_array[$i] != $l){ $r[$i]=$l; } } //adding deleted values foreach($old_array as $i=>$l){ if(!$new_array[$i]){ $r[$i]=""; } } return $r; } http://php.net/manual/en/function.array-diff.php

« previous php.notes (#181862) next »