Grapes are yummy! Don't you like grapes?
-
So, I was digging through our code trying to make a simple change to this God forsaken website when I stumbled upon this beauty. It was under another gem, a custom implementation of strrpos.
function strrpos_rev2($text, $search, $offset = 500) // ============================================================================= { $search = "grapes"; $text = "grapes grapes. Grapes are yummy! Don't you like grapes?";
$text_rev = strrev($substr); $search_rev = strrev($search); $search_length = strlen($search); $text_length = strlen($text); d("text_length: " . $text_length); d("offset: " . $offset); $out = ""; $out .= $text . ""; $out .= "0123456789012345678901234567890123456789012345678901234" . ""; $out .= "0 1 2 3 4 5 " . "<font face="courier">"; $out .= "</font>"; if ($offset) // only use part of the string $text = substr($text, 0, $offset); d($text); $search_start = strripos($text, $search); d("search_start: " . $search_start); $search_length = strlen($search); d("search_length: " . $search_length); $search_stop = $search_start + $search_length; d("search_stop: " . $search_stop); $temp = strripos($text_rev, $search_rev); d("temp: " . $temp); $temp2 = $temp + $search_length; d("temp2: " . $temp2); $pos = $text_length - $temp2; d("pos: " . $text_length); print $out;
}
-
I like consistency in my function results. If the programmer overwrote the contents of the $offset argument as well, this would be perfect!
Or is this in some sick, twisted language which will optionally skip assignments at the start of a function (before any non-assignment lines) if they're the first assignment to one of the function parameters, and that function has a value? I wouldn't *think* this would be from such a convoluted language, as it obviously handles default values through the prototype specification. However, I have seen that feature in a language (I forget which one) that didn't have prototypes, and I have seen a number of languages which included redundant features from other languages, to provide comfort for people used to those specific programming languages.
-
Sorry, you're out of luck. It's PHP my friend.