09-07-2007, 10:36 AM
|
#6 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,239
Thanks: 3
|
Quote:
Originally Posted by Wildhoney
PHP Code:
function getPrefix($szPointer)
{
$aVariable = str_split($szPointer);
$szPrefix = '';
foreach($aVariable as $szVariable)
{
$szOrd = ord($szVariable);
if($szOrd >= 65 && $szOrd <= 90)
{
break;
}
$szPrefix .= $szVariable;
}
return $szPrefix;
}
|
I'm just wondering why you went the route of split/foreach when a simple RegEx would be more readable (personally, I find it easier to glance at a pattern than work through a sequence of loops) and probably quicker? Also, in the case of 'pointers' without an uppercase character (e.g. random) the full string would be returned -- I'd have thought that in that sort of case, there'd logically be no prefix.
|
|
|
|