Posted by <talthen.z-serwera.o2 on 04/09/06 23:53
"Piet" <p.potjer@hccnet.nl>
> 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?
> }
> }
> }
1. "Function", "If" and "For" should be lowercase
2. To break a loop- "break;"
3. To exit from function: "die('message explainging the reason');". You can
use "exit()" alias or just "return 0;".
4. For string comparison you can use substr_compare- should be much faster
then comparing byte by byte in a loop
5. NTG :)
Regards,
Talthen
Navigation:
[Reply to this message]
|