function matchPackageVersion($cur_ver, $for)
{print_r($cur_ver); echo '//'; print_r($for); echo "\n";
// Setup an array of versions.
$versions = explode(',', $for);
foreach ($versions as $ver)
{
// A wildcard (*) version.
if (strpos('*', $ver))
{
// Add a range to the end of $versions.
array_push($versions, str_replace('*', '', $ver) . '-' . str_replace('*', 'z', $ver));
}
// Check if there is a range.
if (strpos('-', $ver))
{
// You can only have one dash for a range. Otherwise it would be rangeS.
if (substr_count($ver, '-') == 1)
{
list($lower, $upper) = explode('-', $ver);
if (version_compare($lower, $cur_ver, '>=') && version_compare($upper, $cur_ver, '<='))
return true;
}
// Uh oh, there are two or more dashes in this!
else
{
$ranges = explode('-', $ver);
foreach ($range as $range)
{
if (!isset($start))
$start = $range;
else
{
array_push($versions, $start . '-' . $range);
}
$start = $range;
}
}
}
else
// Return true if we found the current version in the list of versions.
if (version_compare($ver, $cur_ver, '=='))
return true;
}
return false;
}