what is the Easiest way to do this??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nasr
Forum Newbie
Posts: 13
Joined: Wed Jun 25, 2003 9:29 pm
Location: Cali

what is the Easiest way to do this??

Post by nasr »

ok

let say i have 11 variables with different values.

now i want every variable not to equal another variable from those variables.

example:

i have $m1, $m2, $m3...$m11

ok.. now i dont want $m1!=$m3 and $m2!=$m1 and so on

i hope u know wut i mean.

what is the easiest way to do it?
niceguyeddie
Forum Newbie
Posts: 13
Joined: Fri Nov 28, 2003 7:12 am
Location: Westminster, MD

Post by niceguyeddie »

Easiest would be to use one array and then call array_unique(); if I understand what you mean.

http://www.php.net/manual/en/function.array-unique.php
nasr
Forum Newbie
Posts: 13
Joined: Wed Jun 25, 2003 9:29 pm
Location: Cali

Post by nasr »

Thank u for ur help

they array_unque is not what i was looking for..

but i found it anyway thnx....

i didt a

Code: Select all

<?php
if (max($arr) == min($arr))
{
echo "variables match";

}
?>
nasr
Forum Newbie
Posts: 13
Joined: Wed Jun 25, 2003 9:29 pm
Location: Cali

Post by nasr »

:( actually the above only compared the biggest number and the smallest number in the array. so i did somthing else and it works perfectly, i was just wondering if there is another way to do this

Code: Select all

<?php
<?
$m1 = 1; 
$m2 = 2;
$m3 = 3;
$m4 = 4;
$m5 = 5;
$m6 = 6;
$m7 = 7;
$m8 = 8;
$m9 = 9;
$m10 = 10;
$m11 = 11;

$numbers = array($m1, $m2, $m3, $m4, $m5, $m6, $m7, $m8, $m9, $m10, $m11);
foreach ($numbers as $compare)
{
	echo "Value: $compare\n";

	if ( $m1 !== $compare)
	{
		echo " $m1 and $compare are  not the same\n";
	}
	else 
	{
		echo "$m1 and $compare are the same\n";
	}
	echo "Value: $compare\n";

	if ( $m2 !== $compare)
	{
		echo " $m2 and $compare are  not the same\n";
	}
	else 
	{
		echo "$m2 and $compare are the same\n";
	}
	echo "Value: $compare\n";

	if ( $m3 !== $compare)
	{
		echo " $m3 and $compare are  not the same\n";
	}
	else 
	{
		echo "$m3 and $compare are the same\n";
	}
	echo "Value: $compare\n";

	if ( $m4 !== $compare)
	{
		echo " $m4 and $compare are  not the same\n";
	}
	else 
	{
		echo "$m4 and $compare are the same\n";
	}
	
}

?>
?>
am new to PHP
thnx in advance.
Post Reply