How to write PHP functions
JScript Code
function decode (C) {var digi=16; var add= 10; var plus=7; var cha=36; var I =-1; var H = 0; var B = ""; var J = c.length; var G = c.charcodeat (J-1); C = c.substring (0, J-1); j--; for (var E = 0; E < J; e++) {var D = parseint (C.charat (E), cha)-add; if (d >= add) {d = d-plus} B + = (d). toString (CHA); if (D > H) {I = E; H = D}} var A = parseint (b.substring (0, I), Digi); var F = parseint (b.substring (I + 1), Digi); var L = (A + f-parseint (G))/2; var K = (f-l)/100000; L/= 100000; return {lat:k, lng:l}}document.write (decode (' Hhdfjgzvvihijg '). lat+ ', ' +decode (' HHDFJGZVVIH IJG '). LNG);
The function of this JS function ... How to write in PHP? Thank you, this function run result: 39.09917,117.22348
------Solution--------------------
Literal translation can
PHP Code
Print_r (Decode (' HHDFJGZVVIHIJG ')), function decode ($C) { $digi = +; $add = ten; $plus = 7; $cha =; $I =-1; $H = 0; $B = ""; $J = strlen ($C); $G = Ord ($C {$J-1}); $C = substr ($C, 0,-1); $J--; for ($E = 0; $E < $J; $E + +) { $D = Base_convert ($C {$E}, $cha, ten)-$add; if ($D >= $add) { $D = $D-$plus; } $B. = Base_convert ($D, ten, $cha); if ($D > $H) { $I = $E; $H = $D; } } $A = Base_convert (substr ($B, 0, $I), $digi, ten); $F = Base_convert (substr ($B, $I + 1), $digi, ten); $L = ($A + $F-$G)/2; $K = ($F-$L)/100000; $L/= 100000; Return array (' lat ' = = $K, ' lng ' = $L);}