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... Link to comment https://forums.phpfreaks.com/topic/29965-stristr-weirdness/ 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 Link to comment https://forums.phpfreaks.com/topic/29965-stristr-weirdness/#findComment-137656 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. Link to comment https://forums.phpfreaks.com/topic/29965-stristr-weirdness/#findComment-137678 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.