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
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Beginner needing help

    Here is my code

    Code:
    <?php
    $hamburger = 4.95;
    $choc_mlk_shk = 1.95;
    $cola = 0.85;
    $food = 2 * $hamburger + $choc_mlk_shk + $cola;
    $tax = $food * 0.075;
    $tip = $food * 0.16;
    $total = $food + $tax + $tip;
    printf ("%1d %9s at \$%.2f each: \$%.2f\n", 2, 'Hamburgers', $hamburger, 2 * $hamburger);
    printf ("%1d %9s at \$%.2f each: \$%.2f\n", 1, 'Chocolate Milk Shake', $choc_mlk_shk, $choc_mlk_shk);
    printf ("%1d %9s at \$%.2f each: \$%.2f\n", 1, 'Cola', $cola, $cola);
    printf ("%25s: \$%.2f\n", 'Food and Drink Total', $food);
    printf ("%25s: \$%.2f\n", 'Post Tax Total', $food + $tax);
    printf ("%25s: \$%.2f\n", 'Total', $food + $tax + $tip);
    ?>
    I understand just about everything here. My only question is with %25s and %9s.

    I know that the s is meaning string and gathering the string information, but what are the numbers for?

  • #2
    Regular Coder Nile's Avatar
    Join Date
    Jun 2008
    Posts
    280
    Thanks
    2
    Thanked 46 Times in 46 Posts


  •  

    Posting Permissions

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