本文整理匯總了PHP中phpthumb_functions::version_compare_replacement_sub方法的典型用法代碼示例。如果您正苦於以下問題:PHP phpthumb_functions::version_compare_replacement_sub方法的具體用法?PHP phpthumb_functions::version_compare_replacement_sub怎麽用?PHP phpthumb_functions::version_compare_replacement_sub使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類phpthumb_functions
的用法示例。
在下文中一共展示了phpthumb_functions::version_compare_replacement_sub方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: version_compare_replacement
function version_compare_replacement($version1, $version2, $operator = '')
{
if (function_exists('version_compare')) {
// built into PHP v4.1.0+
return version_compare($version1, $version2, $operator);
}
// The function first replaces _, - and + with a dot . in the version strings
$version1 = strtr($version1, '_-+', '...');
$version2 = strtr($version2, '_-+', '...');
// and also inserts dots . before and after any non number so that for example '4.3.2RC1' becomes '4.3.2.RC.1'.
// Then it splits the results like if you were using explode('.',$ver). Then it compares the parts starting from left to right.
$version1 = eregi_replace('([0-9]+)([A-Z]+)([0-9]+)', '\\1.\\2.\\3', $version1);
$version2 = eregi_replace('([0-9]+)([A-Z]+)([0-9]+)', '\\1.\\2.\\3', $version2);
$parts1 = explode('.', $version1);
$parts2 = explode('.', $version1);
$parts_count = max(count($parts1), count($parts2));
for ($i = 0; $i < $parts_count; $i++) {
$comparison = phpthumb_functions::version_compare_replacement_sub($version1, $version2, $operator);
if ($comparison != 0) {
return $comparison;
}
}
return 0;
}