Hello
I am having problems comparing 2 arrays .
I have $domains[] which contains 3 values
123.com
456.com
789.com
and $data[] which contains 3 values arriving from a data file
566.com
789.com
555.com
I wish to compare the array $domains[] with array $data[] (each value of array $domains[] with
each value of $data[] ) . I wish to echo "OK" if two arrays are the same (==),
I wish to echo "FAIL" if the arrays are not the same.
So the result of the script should be
$domains[] compare result
123.com FAIL
456.com FAIL
789.com OK
I am trying in this way
Code:
...
...
$data_file = '/data.txt';
if (!empty($HTTP_POST_VARS['is_sent'])) process_form();
$data = file($data_file);
$count_data = count($data);
$countx=3;
for ($x = 0; $x < $countx; $x++)
{
echo"$domains[$x]";
for ($xc = 0; $xc <= $count_data-1 ; $xc++)
{
$data[$xr] = trim($data[$xr]);
if ( $domains[$x] == $data[$xc] ) {
echo "OK<br>";
# stop $xc for cycle because condition verified
$xr=$count_data;
}
else
{
echo "FAIL;
}
}
}
but it doesn't work ..
Is there a better way to do the work ?
Thank you!