Kristaps Arbm Posted November 7, 2015 Report Share Posted November 7, 2015 (edited) Sveiki... Tātad man ir kods kurš mani apmierinātu, bet ir problēma kad nepieciešami 2 un vairāk vārdi. Tie ir jāieraksta ar perfektu precizitāti. Man vajadzētu lai sakritība būtu arī tad ja starp šiem 2 vārdiem ir 10 atstarpes. $g = test test; if (strpos (($_POST['msg']), $g) !== false){ echo "Sakrīt"; } ?> Edited November 8, 2015 by Kristaps Arbm Quote Link to comment Share on other sites More sharing options...
waplet Posted November 7, 2015 Report Share Posted November 7, 2015 (edited) Noformulē vēlreiz un lēnām. Edit; O, redzi, uzrakstot visu konkrētāk uzreiz ir risinājums. Edited November 8, 2015 by waplet Quote Link to comment Share on other sites More sharing options...
e-remit Posted November 8, 2015 Report Share Posted November 8, 2015 Šādi derēs? $g = "/test[\s]+test/"; $m = null; $post = "mytest tests"; if (preg_match($g, $post, $m)) { echo "sakrīt!\n"; } Quote Link to comment Share on other sites More sharing options...
Kristaps Arbm Posted November 8, 2015 Author Report Share Posted November 8, 2015 Šādi derēs? $g = "/test[\s]+test/"; $m = null; $post = "mytest tests"; if (preg_match($g, $post, $m)) { echo "sakrīt!\n"; } Ideāli varāk nekā es vēlējos. Pirms tam mēģināju ar preg_match man nesanāca. Esmu vēl zaļš gurķītis php. P.S Liels paldies Daudzsološais profiņš Quote Link to comment Share on other sites More sharing options...
indoom Posted November 10, 2015 Report Share Posted November 10, 2015 (edited) noteikti var arī šitā $g = 'test test'; $post = 'test test'; if (preg_replace('/\s{2,}/', ' ', trim($post)) === $g) { echo "sakrīt!\n"; } Edited November 10, 2015 by indoom Quote Link to comment Share on other sites More sharing options...
jurchiks Posted November 10, 2015 Report Share Posted November 10, 2015 Tā noteikti ir lasāmāk. 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.