...

View Full Version : Resolved hide a value



cosmicsea
01-24-2010, 07:18 PM
Hi im using this code to automatically convert KB into MB

<?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.

MattF
01-24-2010, 07:30 PM
echo (($size > 0) ? $size.'MB' : '');

cosmicsea
01-24-2010, 07:37 PM
echo (($size > 0) ? $size.'MB' : '');


that works great. Thanks again!:thumbsup: I was going at it with the wrong approach.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum