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.

PHP : Nachkommastellen abfragen

Empfohlene Antworten

Veröffentlicht

Hallo Leutz,

wie kann ich am einfachsten ermitteln, ob eine Zahl Nachkommastellen hat?

Hallo Leutz,

wie kann ich am einfachsten ermitteln, ob eine Zahl Nachkommastellen hat?

Gar nicht, denn das liegt ansich nur am Datentyp :)

1 hat keine, aber 1,000 hat welche :D

Was genau meinst du also? Vielleicht ob es eine ganzzahlige Zahl ist?

Goos

versuch ma so:



// beispiel
$No = "1,2536";
echo strstr( $No, ",");
$No2 = "11231";
echo strstr( $No2, ",");

// Mögliche Funktion

function hasDecimalPlace( $string) {
return strstr( $string, ",") !== false
}


[/PHP]

http://de.php.net/manual/de/function.strstr.php

versuch ma so:


$No = "1,2536";
echo strstr( $No, ",");
$No2 = "11231";
echo strstr( $No2, ",");
[/PHP]

Du arbeitest da aber doch nicht wirklich mit Zahlen, sondern mit Strings :D

Goos

Du arbeitest da aber doch nicht wirklich mit Zahlen, sondern mit Strings :D

Goos

geht aber trotzdem,....

PHP castet das intern.

Alertnativ:



$no = 12345;

function hasDecimalPlace( $no) {
return $no != floor( $no);
}
[/PHP]

Hat funktioniert. Danke für die vielen Antworten :beagolisc

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.