Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

kommastellen

Empfohlene Antworten

Veröffentlicht

wie kann ich in php nachkommastellen abschneiden?,

also z.b. 1.234 -> 1.2

hmm.. mir faellt so spontan auch keine funktion ein..

notfalls halt so:

$var1=1.2345;

$tmpvar=$var1*10; // -> 12.345

$tmpvar=floor($tmpvar); // schneidet nachkommateil ab -> 12

$var1=$tmpvar/10; // -> 1.2

oder in kurz:

$var1=floor($var1*10)/10;

geht auch einfacher:

round(1.234,1);

jor, wobei das rundet und nit abschneidet.

kommt halt drauf an obs ne rolle spielt oder nit.

ja, darf ruhig runden. thanx!

wenns nur abschneiden soll dann müsste man wohl so machen:

round(floor(1.234),1);

habs zwar noch nich ausprobiert aber klingt doch gut oder?

ne noch ganz stimmt das nich der rundet nur die 4 weg... hm...

also hier wird nich gerundet =)

<?php

$hinterkomma = 1; // stellen hinterm komma

$wert = 1.234; //zahl die beschnitten werden soll

$gesucht = substr($wert,0,strpos($wert,".")+1+$hinterkomma);

echo $wert."<BR>".$gesucht;

?>

wie sagt man so schön.. alle wege führen nach rom =)

Original geschrieben von nuub

ne noch ganz stimmt das nich der rundet nur die 4 weg... hm...

http://www.php.net/manual/en/function.round.php

float round ( float val [, int precision])

die 1 rundet also die letzte Stelle ab!

Eine 2 würde die letzten beiden Stellen ab etc. pp.

Alles klar?

jo das hatten wir ja schon, aber da wird ja noch gerundet =)

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.