note 105058 deleted from function.array-diff by danbrown

From: Date: Mon, 25 Jul 2011 17:39:18 +0000
Subject: note 105058 deleted from function.array-diff by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181861@lists.php.net to get a copy of this message
Note Submitter: wladimir camarg ---- 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; }

« previous php.notes (#181861) next »