ralph4100 Posted December 8, 2006 Share Posted December 8, 2006 ok here's the code:[code]<?php function checkFor($n) { //let's see if this syntax works... //it's supposed to be true for any variation (regarding capitalization) //of the word 'reset' echo 'checking \''.$n.'\'...'; if(stristr('reset',$n)!==false) { echo 'true'; } else { echo 'false'; } echo '<p>'; } checkFor('reset'); checkFor('RESET'); checkFor('does not contain '); checkFor('does contain reset'); checkFor('rEsEt'); checkFor('ReSeT'); checkFor('reeeeset');?>[/code]and here's the output[code]checking 'reset'...truechecking 'RESET'...truechecking 'does not contain '...falsechecking 'does contain reset'...falsechecking 'rEsEt'...truechecking 'ReSeT'...truechecking 'reeeeset'...false[/code]stristr() should not return false for 'does contain reset' because 'reset' is in the string 'does contain reset'. get me? what's going on here? running php 5.2 btw... Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 8, 2006 Share Posted December 8, 2006 That's because you've reversed the arguments. Stristr's arguments are "haystack", "needle" Not "needle", "haystack" as you have it.Ken Quote Link to comment Share on other sites More sharing options...
ralph4100 Posted December 8, 2006 Author Share Posted December 8, 2006 sometimes programming makes you feel so dumb. 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.