hello all,
i have a php page in which user added certain combinations and clicks on add. when added, i create a array which stores the values and user can add multiple rows.
if ($action=="Add") {
$Arr[] = array (
"scopeid" => $scopeid, // values are comma seperated e.g 1,5,6
"basis" => $basis,
"rate" => $rate,
"currencyid" => $currencyid

i save it to DB. while editing any of the rows in edit mode, i should create a new version of the latest updates. i have tried to do it but could not do it
how to do this comparison. below is my code. hope some one will help me with it
// $arrar1 = values from DB
// $arrar2 = current page values
// or vice versa
function Array_Compare($array1, $array2) {

if (count($array1) != count($array2) ) { // no further comparison reqd
$NewVersionFlag=1; // new version reqd
return $NewVersionFlag;
} else {
$NewVersionFlag=0; // check further values

if ($NewVersionFlag==0) {
// comparing of values goes here
return $NewVersionFlag;
} // end function

Completely lost
Thanks in advance

10 Years
Discussion Span
Last Post by sid_prajapati

U can use the array_search() function
Make sure u use the "===" for comparising.
It should look something like this :

if ($NewVersionFlag==0) 
   foreach($array1 as $value)
         if( array_search($value,$array2) !== 0  )
    if( $i == count($array2) )
             echo 'The two arrays have the same values';
             echo 'The arrays do not correspond'
use array_diff() function that gives you list of array not in both array's

$available = array_diff($array1, $array2);


Edited by sid_prajapati: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.