Here is the code I'm working on. After comparing both arrays, if multiple differences are detected between arr1 and arr2. I should be able to send an email for each difference found. Below, looks like I'm still treating the scalar as an array? Is there a way to make the scalar into array after comparing so I can access the elements individually?
Last edited by Scrutinizer; 09-12-2019 at 02:41 PM..
Reason: code tags
I want a soultion to compare two arrays in sh with an easy way.I want a solution to synchrose users between different AIX servers where no NIS is available. All users are meant to be same on all 10 servers. So the approach is to consider first server as master user repository and whatever the users... (0 Replies)
Hello,
Let's say that we have the two following arrays
@array1=
@array2=
Is there any easy way to compare these two arrays and print the values that exist in array1 and not in array2 and the values that exist in array2 and not in array1?
Regards,
Chriss_58 (3 Replies)
Hi Im supposed to compare lines in a file :
KB0005 1019 T IFVATVPVI 0.691 PKC YES
KB0005 1036 T YFLQTSQQL 0.785 PKC YES
KB0005 1037 S FLQTSQQLK 0.585 DNAPK YES
KB0005 1045 S KQLESEGRS 0.669 PKC YES
KB0005 1045 S KQLESEGRS 0.880 unsp YES
KB204320 1019 T IFVATVPVI 0.699 PKC YES
... (7 Replies)
I have two arrays I need to compare against a third, looking for matches, not differences. I think I'm going to have to convert the arrays to files and grep them, but I'm not too sure if there's a tool to enable me to matches specifically, instead of differences.
Thanks in advance!
Karl (9 Replies)
Hi,
my first post here!
Description of my problem:
I have one txt-file with six rows and each row contains seven numbers seperated with whitespaces.
I want to:
Compare one array with seven numbers with each row of numbers in the txt-file.
I have managed to compare one array with... (6 Replies)
I have the following code and for some reason when I call the program using
/home/tcdata/tatsh/trunk/hstmy/bin/bash/raytrac.bash --cmod=jcdint.cmod
I get
hasArgument =
hasArgument = true
Somehow the array element is returning even though I have not chosen the option.
... (41 Replies)
I've been trying to have an array of ip addresses go through a loop one at a time. Then compare if the current element is in another array of ip addresses. I've traced my error with /bin/bash -x
+ for c in '"${ip}"'
./netk5: line 65: 50.17.231.23 23.64.146.110 23.64.159.139 107.14.36.129... (17 Replies)
Hi,
I am trying to compare two lists that are held in two variables so I believe I need to access the array elements to compare these. I am using ksh 88 and the code I have tried is below:
for file in ${origfilelist}
do
if ]]
then
print -- "File ${file}... (3 Replies)
I have two arrays and they look like this:
array=(`cat /local/mnt/*sys/*includes|grep -v NEW`)
array2=(`cat /tmp/*sys.z |grep -v NEW`)
I am trying to compare them but I need to use the diff -u command. I am not sure how to do this. I cannot just do diff -u ${array} ${array2}
I cannot... (4 Replies)
I have 2 arrays of values for example
A1 ={10 15 3 21}
A2 ={10 15 3 22}
I need to check which one has greater values. However:
A1 ={10 15 3 21}
A2 ={10 15 3 21 3} - this one would be greater.
A1 ={10 15 5 21} - this one greater
A2 ={10 15 3 21}
Basically, I want to compare patch... (6 Replies)
Discussion started by: Jutsimitsu
6 Replies
LEARN ABOUT PHP
array_intersect_ukey
ARRAY_INTERSECT_UKEY(3) 1 ARRAY_INTERSECT_UKEY(3)array_intersect_ukey - Computes the intersection of arrays using a callback function on the keys for comparisonSYNOPSIS
array array_intersect_ukey (array $array1, array $array2, [array $...], callable $key_compare_func)
DESCRIPTION array_intersect_ukey(3) returns an array containing all the values of $array1 which have matching keys that are present in all the argu-
ments.
PARAMETERS
o $array1
- Initial array for comparison of the arrays.
o $array2
- First array to compare keys against.
o $...
- Variable list of array arguments to compare keys against.
o $key_compare_func
- The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to
be respectively less than, equal to, or greater than the second.
int callback (mixed $a, mixed $b)
RETURN VALUES
Returns the values of $array1 whose keys exist in all the arguments.
EXAMPLES
Example #1
array_intersect_ukey(3) example
<?php
function key_compare_func($key1, $key2)
{
if ($key1 == $key2)
return 0;
else if ($key1 > $key2)
return 1;
else
return -1;
}
$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
var_dump(array_intersect_ukey($array1, $array2, 'key_compare_func'));
?>
The above example will output:
array(2) {
["blue"]=>
int(1)
["green"]=>
int(3)
}
In our example you see that only the keys 'blue' and 'green' are present in both arrays and thus returned. Also notice that the values for
the keys 'blue' and 'green' differ between the two arrays. A match still occurs because only the keys are checked. The values returned are
those of $array1.
SEE ALSO array_diff(3), array_udiff(3), array_diff_assoc(3), array_diff_uassoc(3), array_udiff_assoc(3), array_udiff_uassoc(3), array_diff_key(3),
array_diff_ukey(3), array_intersect(3), array_intersect_assoc(3), array_intersect_uassoc(3), array_intersect_key(3).
PHP Documentation Group ARRAY_INTERSECT_UKEY(3)