[PHP] ctype_alpha() alternatief?

Pagina: 1
Acties:
  • 47 views sinds 30-01-2008

  • apNia
  • Registratie: Juli 2002
  • Laatst online: 24-05 21:39

apNia

Schreeuwen en Nibbits eten!

Topicstarter
PHP heeft de functie ctype_alpha() die kijkt of alle characters in $text alpha's zijn. Echter, ik wil controlleren of er EEN alphanummeriek in voorkomt. Weet iemand of PHP daar een alternatieve functie voor heeft? Want wat ik vind zijn alleen ereg() functies die dit oplossen.

Alvast bedankt!

  • Skaah
  • Registratie: Juni 2001
  • Niet online
PHP:
1
2
3
preg_match("!\w+!",$string);
// of
(!empty($string) && ctype_alpha($string))

  • drm
  • Registratie: Februari 2001
  • Laatst online: 09-06-2025

drm

f0pc0dert

Dit kun je het makkelijkst oplossen met inderdaad een ereg of een preg_match. Je zult je daarvoor even moeten verdiepen in regular expressions (zie P&W FAQ - Regular expressions). De oplossing voor dit probleem moet je zelf daarmee wel kunnen vinden.

Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz


Dit topic is gesloten.