GeRik Posted December 3, 2009 Report Share Posted December 3, 2009 $kods = $_POST['kods']; $kods = (preg_match("/[0-9]/",$kods) ); kkas nav ta ja ieraksta piemeram asdasdas595293529 vinjam vaidzetu uzradit 595293529 bet vinsh uzrada 1 Quote Link to comment Share on other sites More sharing options...
briedis Posted December 3, 2009 Report Share Posted December 3, 2009 (edited) Varbūt derētu palasīt php.net manuāli funkcijai? preg_match() returns the number of times pattern matches. That will be either 0 times (no match) or 1 time because preg_match() will stop searching after the first match. preg_match_all() on the contrary will continue until it reaches the end of subject . preg_match() returns FALSE if an error occurred. Varbūt labāk papēti preg_replace() funkciju... Labi, būšu dāsns: $result = preg_replace('/[^0-9]/', '', $subject); Edited December 3, 2009 by briedis Quote Link to comment Share on other sites More sharing options...
GeRik Posted December 3, 2009 Author Report Share Posted December 3, 2009 Varbūt derētu palasīt php.net manuāli funkcijai? Varbūt labāk papēti preg_replace() funkciju... Labi, būšu dāsns: $result = preg_replace('/[^0-9]/', '', $subject); Liels Paldies :) Quote Link to comment Share on other sites More sharing options...
briedis Posted December 3, 2009 Report Share Posted December 3, 2009 Un ko tu no šīs diskusijas iemācījies? Jā, tieši tā - READ THE FUCKING MANUAL! :) Quote Link to comment Share on other sites More sharing options...
marcis Posted December 3, 2009 Report Share Posted December 3, 2009 briedis, tavs regex nosaka, ka pirmajam simbolam jābūt ciparam, pārējie var būt kas vien grib :) Quote Link to comment Share on other sites More sharing options...
briedis Posted December 3, 2009 Report Share Posted December 3, 2009 briedis, tavs regex nosaka, ka pirmajam simbolam jābūt ciparam, pārējie var būt kas vien grib :) Hmm, nez, man liekas, ka mans regexps aizstāj visus simbolus, kas nav 0-9 ar tukšumu :) Quote Link to comment Share on other sites More sharing options...
thesnarkie Posted December 3, 2009 Report Share Posted December 3, 2009 http://txt2re.com/index.php3 Headache relief for programmers. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.