note 12937 deleted from function.strrpos by didou
| From: | didou@php.net | Date: | Sun, 10 Aug 2003 03:10:21 +0000 |
| Subject: | note 12937 deleted from function.strrpos by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-53795@lists.php.net to get a copy of this message | ||
Note Submitter: msopacua@idg.nl
----
At least in php3.0.6 strrpos does NOT return zero (ie. an integer 0 value) but an empty value, which
makes any integer tests unusable.
Code example, using intval() to counter this:
<code>
if(strlen($reactie) > 125)
{
$cutoff_space=intval(strrpos(substr($reactie,0,125), " "));
$cutoff_dot=intval(strrpos(substr($reactie,0,125), "."));
$cutoff_comma=intval(strrpos(substr($reactie,0,125), ","));
if(125 - $cutoff_dot < 15)
{
$cutoff=$cutoff_dot+1;
}
else if(125 - $cutoff_comma < 15)
{
$cutoff=$cutoff_comma+1;
}
else
{
$cutoff=max($cutoff_space, $cutoff_dot, $cutoff_comma)+1;
}
$expert=substr($reactie,0,$cutoff);
}
else
{
$expert=$reactie;
}
</code>