File Size for Linked File - line breaks
Posted: Thu Aug 20, 2009 2:27 pm
Hello,
I'm using the following code to generate a filesize for a linked file:
...and in the page I'd call the function by including:
...which would echo:
However, for some reason the output is not working as planned. Instead of showing this:
...the output is creating line breaks:
Can anyone help explain why the output is taking the link outside of the paragraph and creating line breaks that shouldn't exist?
Thanks,
Mark
I'm using the following code to generate a filesize for a linked file:
Code: Select all
<?php
$file_type = array( 'K', 'M', 'G' );
$size = filesize ( $f );
for ( $t = 0; $size > 1024; $t++ )
{
$size /= 1024;
$file_size = round ( $size, 1 ) . ' ' . $file_type[ $t ] . 'B';
}
$file_name = substr($f, -(strlen($f) - strrpos($f,'/')));
echo "<a href=\"$f\" class=\"pdf\" title=\"$file_size\">";
list($f, $ext) = explode('.', $f);
echo basename($f);
echo " <small>($file_size)</small></a>";
?>Code: Select all
<?php $f = "My Event.pdf";?>Code: Select all
<a href="My Event.pdf" class="pdf" title="82 KB">My Event<small>(82 KB)</small></a>
Code: Select all
Watch out for [u]My Event (82 KB)[/u] - the vital source of LOCAL information. [u]Click here for more information[/u].
Code: Select all
Watch out for - the vital source of LOCAL information. [u]Click here for more information[/u].
My Event (82 KB)Thanks,
Mark