---
title: "Förenkla if-sats"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/131095-förenkla-if-sats"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "Melea"
published: "2005-07-07T17:38:02.000Z"
updated: "2005-07-07T18:35:56.000Z"
replies: 2
views: 268
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/131095-förenkla-if-sats"
---

# Förenkla if-sats

## #1 — Melea, 2005-07-07T17:38Z

Tjena!

Har tänkt och tänkt, men kommer inte på någon lösning, jag har en if-sats som kollar filändelserna vid uppladdning av dokument

```php
if($fileend == '.doc' || $fileend == '.pub' || $fileend == '.txt' || $fileend == '.pps' || $fileend == '.ppt' || 
$fileend == '.pot' || $fileend == '.ppa' || $fileend == '.pdf' || $fileend == '.xls' || $fileend == '.zip' || 
$fileend == '.rar' || $fileend == '.tar' || $fileend == '.rtf') {
```

Går det att förenkla detta på något vis? Genom arrayer, men hur? :OO

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

## #2 — Gislaved, 2005-07-07T17:53Z

```php
<?
# Fyll på med dina filändelser
$fileendings = array(".doc", ".pdf", ".txt", ".xls");

# Kolla om den finns med i listan
if (in_array($filend, $filendings)) {
   echo "Okidoki!";
}
?>
```

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

## #3 — Melea, 2005-07-07T18:35Z

Lysande, tack!

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

---

Tråden på webben: https://www.webforum.nu/amne/php/131095-förenkla-if-sats
