blurredvision Posted September 9, 2008 Share Posted September 9, 2008 I haven't quite learned expressions yet, so I was hoping somebody could quickly give me the right to code to check a variable for the absence of a period. Thanks! Link to comment https://forums.phpfreaks.com/topic/123435-expression-to-check-for-the-absence-of-a-period/ Share on other sites More sharing options...
JasonLewis Posted September 9, 2008 Share Posted September 9, 2008 No expression required... <?php $string = "This has a full stop."; if(!strpos($string, ".")){ echo "No fullstop!"; }else{ echo "Full stop is present!"; } ?> Link to comment https://forums.phpfreaks.com/topic/123435-expression-to-check-for-the-absence-of-a-period/#findComment-637495 Share on other sites More sharing options...
lanmonkey Posted September 9, 2008 Share Posted September 9, 2008 Expression to check for the absence of a period? Well, if shes is pre-menopausal and not married yet then I would say shock. Link to comment https://forums.phpfreaks.com/topic/123435-expression-to-check-for-the-absence-of-a-period/#findComment-637500 Share on other sites More sharing options...
discomatt Posted September 9, 2008 Share Posted September 9, 2008 No expression required... <?php $string = "This has a full stop."; if(!strpos($string, ".")){ echo "No fullstop!"; }else{ echo "Full stop is present!"; } ?> No no no no Strpos returns an in, which can be 0... if $string = '.somestring', your if statement willl return true. Use this instead <?php $string = "This has a full stop."; if( strpos($string, ".") === FALSE ){ echo "No fullstop!"; }else{ echo "Full stop is present!"; } ?> Well, if shes is pre-menopausal and not married yet then I would say shock. Mint. Link to comment https://forums.phpfreaks.com/topic/123435-expression-to-check-for-the-absence-of-a-period/#findComment-637535 Share on other sites More sharing options...
JasonLewis Posted September 10, 2008 Share Posted September 10, 2008 No no no no Strpos returns an in, which can be 0... if $string = '.somestring', your if statement willl return true. Use this instead Man I always do that. Cheers! Link to comment https://forums.phpfreaks.com/topic/123435-expression-to-check-for-the-absence-of-a-period/#findComment-638141 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.