Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    ivy
    ivy is offline
    Regular Coder
    Join Date
    Jun 2002
    Location
    London / Glasgow / Liverpool
    Posts
    177
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Strange result using eregi_replace - help!

    Hi there.

    I have a database with some figures in it and they are formatted as decimals with one figure after decimal place.

    If the figure finishes in .0 I want to remove the .0
    If the figure ends in .1 (to .9) then I want to keep it

    I used the following:

    PHP Code:
    echo eregi_replace('.0'''$row['figure']).'  cms'
    Strange thing that happens is that when the figure in the database is 20.0 I get no figure displayed! I just get "cms". If I change the figure to 21.0 in the database, it displays it perfectly!

    I cannot see why this would be!

    Any help trulty appreciated!
    See ya

    Ivy.

    MAC Codes

  • #2
    ivy
    ivy is offline
    Regular Coder
    Join Date
    Jun 2002
    Location
    London / Glasgow / Liverpool
    Posts
    177
    Thanks
    1
    Thanked 0 Times in 0 Posts
    It's OK - I have solved it!

    I forgot to put the backslash before the period:

    PHP Code:
    echo eregi_replace('\.0'''$row['figure']).'  cms'
    That has done the trick!

    I was looking at it for ages! Time for a break I think!
    See ya

    Ivy.

    MAC Codes


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •