Jump to content

[SOLVED] Help Please , To Change , to . ( SOLVED) Thanks


just me and php

Recommended Posts

Heres My Problem
Users Are Posting Race Times To My Database Then I Have That Output To A php Page And It All Works Great, With A Lot Of Help From You Guys.
New Problem , I Guess Different Countrys Post Different Number Formats Or Something Like That So Now Im Getting This.
0:51,96 lap time
1:19,19 
0:35,36

Is There A Code That Would Change The ,,,,, To ..... So It Looks Like This
0:08.33 lap time
0:02.62
1:09.23
I Would Like To Change It In My php Page So I Dont Need To Mess With Database Or The Input Script To Database.

Thanks
Link to comment
Share on other sites

You can use [url=http://www.php.net/manual/en/function.preg-replace.php]preg_replace[/url] to replace all occurences of "," with "."
Here is a little example:
[code=php]<?php
//Your lap time, get it from DB or whatever
$time = '0:51,96 lap time';

//Remplace "," (comma) with "." (dot)
//Multiple commas are trimmed down to one dot
$time = preg_replace ('#,+#', '.', $time);

echo $time;
?>[/code]

I hope this is what you're looking for.

BTW, the above will replace multiple commas with just one dot.
[b]0:51,,,,,,,,,,,,96 lap time[/b] will result [b]0:51.96 lap time[/b]

Boby
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.