Jump to content

Expression to check for the absence of a period?


blurredvision

Recommended Posts

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 :D 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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.