---
title: "Loopa \"kod\""
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/49577-loopa-kod"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "ThACRoW"
published: "2002-08-05T16:33:54.000Z"
updated: "2002-08-05T16:54:26.000Z"
replies: 2
views: 172
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/49577-loopa-kod"
---

# Loopa "kod"

## #1 — ThACRoW, 2002-08-05T16:33Z

Med "kod" menar jag att jag vill loopa uttryck i en if-sats. Tex:

```
if ( $exception[$key] && $$key != $exception[$key][0]
                      && $$key != $exception[$key][2]
                      && $$key != $exception[$key][4]
                      && $$key != $exception[$key][6]
                      && $$key != $exception[$key][8]
                      && $$key != $exception[$key][10]
                      && $$key != $exception[$key][12] ) // loopen ska fortsätta fram till ett angett nummer.
```

Finns det något finurligare sätt att lösa detta på?
Fundera inte på vad jag ska ha det till :)

Permalänk: https://www.webforum.nu/p/49577

## #2 — LarsG, 2002-08-05T16:45Z

```php
if ( $exception[$key] ) {
   $b = 0;
   for ( $i = 0; $i <= $antal; $i += 2 ) {
         if  ( $$key == $exception[$key][$i] ) {
             $b++;
             break;
         }
  }
  if ( !$b ) { //
  }
}
```

Permalänk: https://www.webforum.nu/p/744145

## #3 — ThACRoW, 2002-08-05T16:54Z

Wow. Är verkligen imponerad.
Hade ju aldrig tänkt ut en sån lösning själv.

Iof har jag inte testat om det fungerar ännu, men det gör det säkert. Jag förstår i alla fall hur du har tänkt :) 

Tusen tack!

Permalänk: https://www.webforum.nu/p/744150

---

Tråden på webben: https://www.webforum.nu/amne/php/49577-loopa-kod
