Difference between revisions of "PHP RegionFunctions"
Jump to navigation
Jump to search
(Three useful PHP functions by Gypsy Paz and Zayne Exonar) |
m (language tags to <source>) |
||
(15 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
<source lang="php"> | |||
// Three useful PHP functions by Gypsy Paz and Zayne Exonar | // Three useful PHP functions by Gypsy Paz and Zayne Exonar | ||
// $coords[0] = Global Grid X coordinate | // $coords[0] = Global Grid X coordinate | ||
// $coords[1] = Global Grid Y coordinate | // $coords[1] = Global Grid Y coordinate | ||
function getSimName($coords){ | function getSimName($coords) | ||
{ | |||
$split = explode('"', file_get_contents("http://slurl.com/get-region-name-by-coords?var=region&grid_x=".$coords[0]."&grid_y=".$coords[1])); | $split = explode('"', file_get_contents("http://slurl.com/get-region-name-by-coords?var=region&grid_x=".$coords[0]."&grid_y=".$coords[1])); | ||
return $split[1]; | return $split[1]; | ||
} | } | ||
function getSimCoords($simName){ | |||
function getSimCoords($simName) | |||
{ | |||
$query = str_replace(" ", "", file_get_contents("http://slurl.com/get-region-coords-by-name?var=coords&sim_name=".urlencode($simName))); | $query = str_replace(" ", "", file_get_contents("http://slurl.com/get-region-coords-by-name?var=coords&sim_name=".urlencode($simName))); | ||
$coords = preg_split('/[a-zA-Z=",.:;}{]/', $query, -1, PREG_SPLIT_NO_EMPTY); | $coords = preg_split('/[a-zA-Z=",.:;}{]/', $query, -1, PREG_SPLIT_NO_EMPTY); | ||
Line 16: | Line 22: | ||
} | } | ||
function getSimImage($coords){ | |||
function getSimImage($coords) | |||
{ | |||
return "http://map.secondlife.com/map-1-".$coords[0]."-".$coords[1]."-objects.jpg"; | return "http://map.secondlife.com/map-1-".$coords[0]."-".$coords[1]."-objects.jpg"; | ||
} | } | ||
</source> |
Latest revision as of 07:30, 25 January 2015
// Three useful PHP functions by Gypsy Paz and Zayne Exonar
// $coords[0] = Global Grid X coordinate
// $coords[1] = Global Grid Y coordinate
function getSimName($coords)
{
$split = explode('"', file_get_contents("http://slurl.com/get-region-name-by-coords?var=region&grid_x=".$coords[0]."&grid_y=".$coords[1]));
return $split[1];
}
function getSimCoords($simName)
{
$query = str_replace(" ", "", file_get_contents("http://slurl.com/get-region-coords-by-name?var=coords&sim_name=".urlencode($simName)));
$coords = preg_split('/[a-zA-Z=",.:;}{]/', $query, -1, PREG_SPLIT_NO_EMPTY);
return $coords;
}
function getSimImage($coords)
{
return "http://map.secondlife.com/map-1-".$coords[0]."-".$coords[1]."-objects.jpg";
}