note 74690 added to control-structures.foreach
| From: | jeff at trunkofjunk dot com | Date: | Mon, 23 Apr 2007 19:17:28 +0000 |
| Subject: | note 74690 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-125804@lists.php.net to get a copy of this message | ||
#
# compare_arrays($array1,$array2)
# compare 2 similar arrays and return any different values - left overtakes the right -
#
function compare_arrays($array1,$array2) {
if ( is_array($array1) ) {
foreach ( $array1 as $key1 => $value1 ) {
if ( is_array($array2) ) {
foreach ( $array2 as $key2 => $value2 ) {
if ( $key1 == $key2 ) {
if ( is_array($value1) ) {
$this->compare_arrays($value1,$value2);
}
if ( isset($value1) && $value1 !==
$value2 ) {
$changed[$key1] = $value1;
}
}
}
}
}
}
return $changed;
} // end compare_arrays()
----
Server IP: 69.39.81.135
Probable Submitter: 65.126.226.1
----
Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php
Edit -- https://master.php.net/note/edit/74690
Del: integrated -- https://master.php.net/note/delete/74690/integrated
Del: useless -- https://master.php.net/note/delete/74690/useless
Del: bad code -- https://master.php.net/note/delete/74690/bad+code
Del: spam -- https://master.php.net/note/delete/74690/spam
Del: non-english -- https://master.php.net/note/delete/74690/non-english
Del: in docs -- https://master.php.net/note/delete/74690/in+docs
Del: other reasons-- https://master.php.net/note/delete/74690
Reject -- https://master.php.net/note/reject/74690
Search -- https://master.php.net/manage/user-notes.php