[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] [PHP] printf formatterer ikke bredde



Christoffer Holm Kjølbæk wrote:

Det kan den også sagtens, hvis du kigger i på HTML kode som dit script
spytter ud, så er der alle de mellemrum der skal være.

Problemet er bare, at flere mellemrum efter hinanden i et HTML dokument
bliver lavet om til et. Hvis du kan få printf til at skifte alle
mellemrum ud med " ", så vil du få den ønskede effekt.

Dog vil det jo ikke virke som i en terminal, med mindre du bruger en
skrifttype hvor alle karaktere er lige bredde. En anden mulighed er at
bruge <pre>, hvilket netop bruger karaktere med lige bredde. Ulempen er
så, at der ikke er mulighed for layout:

<?php
$total = 20;
echo "<pre>";
printf("%25s \$%.2f", 'Total', $total);
echo "</pre>";
?>

Tak for svarene til dig og Håkan.

Er der ikke en ofte anvendt løsning på dette problem i PHP?

Det virker i øvrigt for mig underligt at man i et sprog som decideret er beregnet til hypertext processering har implementeret printf så den netop i hypertext ikke formatterer output bredde ud fra den angivne mindstebredde - men det er der måske en grund til?

Med venlig hilsen
David List


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2007-11-01, 02:01 CET [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *