Zahlen erkennen

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Zahlen erkennen

    Weiss jemand gerade zufällig, wie ich aus einem String die Zahlen herauspicken kann? Gibt es dafür ein Befehl?
    Ich finde momentan nichts.

    Hochachtungsvoll
    pingzaong

  • #2
    Sorry Edit: preg_match_all('/[0-9]/', $str, $ergebnisarray);
    Last edited by Pennywise; 03-01-2006, 15:07.

    Comment


    • #3
      Dankeschön, war hilfreich.
      Hochachtungsvoll
      pingzaong

      Comment


      • #4
        und falls du eigentlich nicht die zahlen aus einem string picken willst, sondern nur alle nicht-zahlen entfernen willst, kannst du das so machen ....

        PHP Code:
        $str preg_replace('/[^0-9]/'''$str); 
        INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


        Comment


        • #5
          Oder
          PHP Code:
          preg_match_all('/\\d/',$str,$array);
          //oder
          preg_replace('/\\D/','',$str); 
          Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

          [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
          Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

          Comment


          • #6
            cool, ich werde es zur Kenntnis nehmen.
            Hochachtungsvoll
            pingzaong

            Comment

            Working...
            X