PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : MIN( ) in PHP



RPG-Man
04.09.2006, 19:15
Hallo Leutz,

Gibt es in PHP so eine Funktion wie MIN in Excel?

nudelsalat
04.09.2006, 19:17
- www.google.de -> "php min()"
- erstes ergebnis
- ???
- profit.

RPG-Man
10.09.2006, 14:11
Jetzt ist da ein neues Problem. Wie kann man das realisieren, dass er die 0 egal ob eine Variable 0 hat weglässt. Ich muss nämlich eine Exceltabelle in PHP realisieren.

dead_orc
10.09.2006, 14:36
Jetzt ist da ein neues Problem. Wie kann man das realisieren, dass er die 0 egal ob eine Variable 0 hat weglässt. Ich muss nämlich eine Exceltabelle in PHP realisieren.
WTF? Exceltabelle in PHP? Naja, falls ich dich richtig verstanden habe, kannst du doch einfach

if($var == '0') $var = '';
machen o.o

RPG-Man
10.09.2006, 14:48
WTF? Exceltabelle in PHP? Naja, falls ich dich richtig verstanden habe, kannst du doch einfach

if($var == '0') $var = '';
machen o.o

Ich meine mehr das er innerhalb der MIN-Funktion die Variable mit 0 weglässt und stattdessen die kleinste Zahl, die größer als 0 ist, nimmt.

dead_orc
10.09.2006, 15:05
Aso. Kenn mich mit Excel nicht so aus ^^
Naja, etwas Code wäre nicht schlecht. Ich würde das wohl mit nem Array, in dem alle Werte stehen, aus dem ich dann alle Nullen rausfilter und dann nach numerischer Größe sortiere machen:

$values = array(-19, 5, 3, 0, 1, 7.5, 30);
$values = array_filter($values, create_function('$var', 'return ($var != 0 AND (is_int($var) OR is_float($var)));'));
sort($values);
echo $values[0];
tested

RPG-Man
11.09.2006, 17:38
$Vfünf_60n = array($adsl_fünf_60n,$avic_fünf_60n,$awib_fünf_60n,$Diba_fünf_60n,$DSLStar_fünf_60n,$IFSDKB_fünf_60n,$IFSDSL_fünf_60n,$IFSGMAC_fünf_60n,$IFSWIB_fünf_60n,$PSD_fünf_60n);
$Vfünf_60n = array_filter($Vfünf_60n, create_function('$var', 'return ($var != 0 AND (is_int($var) OR is_float($var)));'));
sort($Vfünf_60n);
echo $Vfünf_60n[0];



Ab der arrayfilterfunktion scheint es nicht mehr zu funktionieren.