question about modifying an integer..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Gonik
Forum Newbie
Posts: 19
Joined: Fri Aug 30, 2002 7:39 am
Location: Somewhere Around Nothing

question about modifying an integer..

Post by Gonik »

hello, first post here :)

anyway here's my question. Let's assume that I have the integer 100. I want to add a dot (.) AFTER the first digit, so it will become 1.00. I have many integer like this stored in a db. I think that I will do it using the ereg() function, but can you please give me a clue?

thank you!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

try

Code: Select all

$number=preg_replace('!^(ї0-9])(.*)!', '$1.$2', $number)
User avatar
Gonik
Forum Newbie
Posts: 19
Joined: Fri Aug 30, 2002 7:39 am
Location: Somewhere Around Nothing

Post by Gonik »

Yes it worked! thank you m8! :)
Post Reply