# Problem bei Funktion $iflonger

**URL:** <https://community.mp3tag.de/t/problem-bei-funktion-iflonger/16119>\
**Category:** Allgemein\
**Created:** [September 9, 2014, 10:11am UTC](https://community.mp3tag.de/t/problem-bei-funktion-iflonger/16119 "2014-09-09T10:11:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)\
**Post date:** [September 9, 2014, 10:11am UTC](https://community.mp3tag.de/t/problem-bei-funktion-iflonger/16119/1 "2014-09-09T10:11:27Z")

</div>

Gibt es ein Problem bei der Funktion $iflonger ?

Die Regel:  
$iflonger(a,b,x,y) wenn a länger b Zeichen ist, wird x zurück geliefert, andernfalls y.

**$iflonger('abc',,'yes','no')==\> 'yes' $iflonger('abc','a','yes','no')==\> 'yes' $iflonger('abc','ab','yes','no')==\> 'yes' $iflonger('abc','abc','yes','no')==\> 'yes' (should be 'no') $iflonger('abc','abcd','yes','no')==\> 'yes' (should be 'no')**

Das funktioniert ...

**$ifgreater($len('abc'),$len(),'yes','no')==\> 'yes' $ifgreater($len('abc'),$len('a'),'yes','no')==\> 'yes' $ifgreater($len('abc'),$len('ab'),'yes','no')==\> 'yes' $ifgreater($len('abc'),$len('abc'),'yes','no')==\> 'no' $ifgreater($len('abc'),$len('abcd'),'yes','no')==\> 'no'**

... und so funktioniert es auch ...

**$iflonger('abc',0,'yes','no') ==\> 'yes' $iflonger('abc',1,'yes','no') ==\> 'yes' $iflonger('abc',2,'yes','no') ==\> 'yes' $iflonger('abc',3,'yes','no') ==\> 'no' $iflonger('abc',4,'yes','no') ==\> 'no'**

Das Problem hat sich erledigt!

DD.20140909.1427.CEST

---

<div class="post-metadata">

**Author:** ![Roland](https://community.mp3tag.de/user_avatar/community.mp3tag.de/roland/32/8001_2.png) [@Roland](https://community.mp3tag.de/u/Roland)\
**Post date:** [December 19, 2021, 5:13pm UTC](https://community.mp3tag.de/t/problem-bei-funktion-iflonger/16119/2 "2021-12-19T17:13:21Z")

</div>

Ich verstehe die Erklärung/Lösung noch nicht. 🤔

> Blockquote **$iflonger('abc','abcd','yes','no') ==\> 'yes' (should be 'no')**  
> Wieso YES?

> Blockquote **$ifgreater($len('abc'),$len('abcd'),'yes','no') ==\> 'no'**  
> Geht es tatsächlich nur so?

Wie finde ich den längeren String mit $iflonger ?

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [December 19, 2021, 6:18pm UTC](https://community.mp3tag.de/t/problem-bei-funktion-iflonger/16119/3 "2021-12-19T18:18:24Z")

</div>

> [@Roland](#):
>
> Wie finde ich den längeren String mit $iflonger ?

Die englische Hilfe sagt:  
**$iflonger(a,b,x,y)** if string a is longer than number b, x is returned, otherwise y.  
Die deutsche:  
**$iflonger(a,b,x,y)** Wenn a länger b Zeichen ist, wird x zurück geliefert, andernfalls y.

leider wird im deutschen nicht klar, dass b eine Zahl sein muss.

Wenn du 2 Längen vergleichen willst (und nicht überprüfen, ob ein String länger als eine vorgegebene Zahl), dann musst du die Länge erst in eine Zahl umwandeln mit $len().  
**$iflonger('abc','abcd','yes','no') ==\> 'yes' (should be 'no')** liefert "yes", weil der String abcd als Zahl 0 liefert.  
Zum Vergleich mit $iflonger() müsste es sein:  
`$iflonger('Abcd',$len('abc'),yes,no)`

---

<div class="post-metadata">

**Author:** ![Roland](https://community.mp3tag.de/user_avatar/community.mp3tag.de/roland/32/8001_2.png) [@Roland](https://community.mp3tag.de/u/Roland)\
**Post date:** [December 20, 2021, 10:00am UTC](https://community.mp3tag.de/t/problem-bei-funktion-iflonger/16119/4 "2021-12-20T10:00:46Z")

</div>

Excellent explanation, thank you.  
 ![Snoopy Xmas-10](https://community.mp3tag.de/uploads/default/original/2X/6/608d1626a112b59c718141282402e1a4a6d7bd60.gif)

Happy Xmas!

---

<div class="post-metadata">

**Author:** ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)\
**Post date:** [March 1, 2025, 7:46am UTC](https://community.mp3tag.de/t/problem-bei-funktion-iflonger/16119/5 "2025-03-01T07:46:32Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
