0
I’m developing a game that performs a function in Javascript that clocks how long it took the player to finish to reach the last stage:
function formatatempo(segs) {
var min = 0;
va hr = 0;
while (segs >= 60) {
if (segs >= 60) {
segs = segs - 60;
min = min + 1;
}
}
while (min >= 60) {
if (min >= 60) {
min = min - 60;
hr = hr + 1;
}
}
if (hr < 10) {
hr = "0" + hr
}
if (min < 10) {
min = "0" + min
}
if (segs < 10) {
segs = "0" + segs
}
fin = hr + ":" + min + ":" + segs
return fin;
}
In the above case, at the end of the execution the variable fin
is returned with time travelled. The problem, is that I need to store these outputs in a ranking, how could I sort them in a way that takes from the smallest to the longest time?
If you return the results in timestamp is very easy to sort, just bring from the smallest to the largest.
– Bruno Wego
the problem is that I am not able to slice the variable I took from JS and passed PHP into an array : $fin = "<script>Document.write(fin)</script>"; the function explodes from PHP does not accept this,
– Gabriel Longatti
Dude this is Javascript, not php, you have to know the difference between the two. In addition, the javascript language is client-side only and not server-side.
– Ivan Ferrer