Jump to content
php.lv forumi

str tikai cipari


ohmygod

Recommended Posts

ir formas lauks, kuraa ievadaas skaits.

eregi("[0-9]{1,2}",$sk)

tjip paarbaudu saturu, driikst buut viens vai divi cipari.

Nekas vairaak, bet - probleema sleepjas tur, ka var ievadiit vienu ciparu un vienu burtu.

:/ baigi slikti - man tas neder. Kaa man pareizi uzrakstiit stringa paarbaudi, lai tajaa driiksteetu atrasties TIKAI cipari? viens vai divi...

es jau, kaa dumsh buudams - sadomaaju, ka jaacheko str garums un tad atkariibaa no taa {} jaaliek konkreetais skaits... a mok taa ij dariit?

tik liekas ka tas nebuut pareizi (: varbuut kaads vispaar var normaalaa valodaa apskaidrot, kaa shitie visi pareizi rakstaas...

Link to comment
Share on other sites

te jāuzmanās

The value is given by the initial portion of the string. If the string starts with valid numeric data, this will be the value used. Otherwise, the value will be 0 (zero). Valid numeric data is an optional sign, followed by one or more digits (optionally containing a decimal point), followed by an optional exponent. The exponent is an 'e' or 'E' followed by one or more digits.

 

resp. (int)'2a'==2

Link to comment
Share on other sites

×
×
  • Create New...