Archive

Archive for December 1, 2009

PHP TIPS #4 – Array_diff_uassoc Function in PHP

December 1, 2009 Leave a comment

Function Description:

array_diff_uassoc() function which compares two or more arrays while checking for differences before comparing the keys with a user-defined location. It then returns an array withthe keys and values from the first array(to which all the values were comapred against) it the function allows it.

Syntax is as follows : array_diff_uassoc(array1,array2,array3….,function).

with a sample below of how it is used.

function userdefined($v1,$v2)
{
if ($v1 === $v2)
{
return 0;
}
if ($v1 > $v2)
{
return 1;
}
else
{
return -1;
}
}
$a1=array(0=>”Dog”,1=>”Cat”,2=>”Horse”)
$a2=array(3=>”Dog”,1=>”Cat”,5=>”Horse”)
print_r(array_diff_uassoc($a1,$a2,”userdefined”));
?>

which results in the following output : Array( [0] => Dog [2] => Horse). For an example of the same function with two or more assigned arrays to the function:

function userdefined($v1,$v2)
{
if ($v1 === $v2)
{
return 0;
}
if ($v1 > $v2)
{
return 1;
}
else
{
return -1;
}
}
$a1=array(0=>”Dog”,1=>”Cat”,2=>”Horse”)
$a2=array(3=>”Dog”,1=>”Cat”,5=>”Horse”)
$a3=array(6=>”Onyx”,0=>”Dog”,5=>”Horse”)
print_r(array_diff_uassoc($a1,$a2,$a3,”userdefined”));
?>

Which in turn, gives you : Array ([2] => Horse )

So we see the different array_diff function variants and the diffeerent ways they are used to compare the values of one or more arrays with one another.

PHP Fresher/Trainee in Chennai

December 1, 2009 Leave a comment

COMPANY: SPACE COMPUTER AND SYSTEMS LTD

JOB DESCRIPTION:

Candidates  have to undergo hands on training in web2.0 technologies which includes Javascript and Ajax, PHP, C# and ASP.Net, Java/J2EE, MySQL, XML, Web 2.0 framework, Mashups, Dojo widgets, Echo2, Ajax security framework and toolkit including Web 2.0 enterprise. Post training upon their evaluation candidates will be taken in for Live projects in Web based Applications.
POSITION REQUIREMENTS:
Any Eng gradutes with Computer science /IT background and candidates who are willing to shift their career to web technologies shallapply.
CONTACT: HR, training@spacecs.com
Job ID: 3926
Location: Chennai
Follow

Get every new post delivered to your Inbox.