compare

compare

am 08.04.2006 17:17:22 von Piet

How can I stop a function in PHP?

When comparing data I want to stop the function on a hit.



Function compare($data) {

For ($n=1; $n<=10000; $n++) {

For ($m=1; $m<=10000; $m++) {

If $data[$n]==data[$m] {

.

Exit function, or exit for.. --- but how?

}

}

}

How can I avoid comparing 10000 * 10000 times?



Thanks



Piet

Re: compare

am 08.04.2006 19:41:11 von Aggro

Piet wrote:
> How can I stop a function in PHP?

By calling return;

function example()
{
return; // stop here

echo "test"; // This is never executed
}