Here are some snippets that support the new Steam3 format.
PHP (with GMP, but should be easy to convert to BCMath):
PHP Code:
function getCommunityId($steamId)
{
$accountId = 0;
if (preg_match('/^STEAM_[0-9]:([0-9]):([0-9]+)$/i', $steamId, $matches)) {
$accountId = $matches[1] + ($matches[2] * 2);
}
if (preg_match('/^\[U:[0-9]:([0-9]+)\]$/i', $steamId, $matches)) {
$accountId = $matches[1];
}
return gmp_strval(gmp_add('76561197960265728', $accountId));
}
MySQL (it's a bit of a monster):
PHP Code:
SELECT
(CASE
WHEN steam_id LIKE "STEAM_%" THEN 76561197960265728 + CAST(SUBSTRING(steam_id, 9, 1) AS UNSIGNED) + CAST(SUBSTRING(steam_id, 11) * 2 AS UNSIGNED)
WHEN steam_id LIKE "[U:%]" THEN 76561197960265728 + CAST(SUBSTRING(steam_id, 6, CHAR_LENGTH(steam_id) - 6) AS UNSIGNED)
END) AS community_id
__________________