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 3 of 3

Thread: hide a value

  1. #1
    Regular Coder
    Join Date
    Jan 2010
    Location
    Washington
    Posts
    223
    Thanks
    34
    Thanked 0 Times in 0 Posts

    hide a value

    Hi im using this code to automatically convert KB into MB
    PHP Code:
    <?php
    $size 
    $data['size'];
    $size preg_replace("#[a-z]#i"''$size);
    $size round($size/1024);
    echo 
    $size.'MB';
    ?>
    I want to make it so when no KB is available for it to be blank. right now when no KB is available it prints 0MB and i want that hidden. can someone help me? Thanks.
    Last edited by cosmicsea; 01-24-2010 at 07:38 PM.

  • #2
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Code:
    echo (($size > 0) ? $size.'MB' : '');

  • Users who have thanked MattF for this post:

    cosmicsea (01-24-2010)

  • #3
    Regular Coder
    Join Date
    Jan 2010
    Location
    Washington
    Posts
    223
    Thanks
    34
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by MattF View Post
    Code:
    echo (($size > 0) ? $size.'MB' : '');
    that works great. Thanks again! I was going at it with the wrong approach.


  •  

    Posting Permissions

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