Jump to content

[SOLVED] making a new line in php


silverglade

Recommended Posts

hi, im new to php and was wondering how i can insert new lines into all the output lines in this code, any help greatly appreciated. derek

 

<?php
$money = 30;
$pet = "Kitten";
$new = sprintf("It costs $%3.2f for a %s.\n",$money,$pet);

$new2 = sprintf("%'.-20s%3.2f",$pet,$money);
echo $new;

echo $new2;
$today = date("Y/m/d");

echo $today;
?>

Link to comment
https://forums.phpfreaks.com/topic/115846-solved-making-a-new-line-in-php/
Share on other sites

hi, im new to php and was wondering how i can insert new lines into all the output lines in this code, any help greatly appreciated. derek

 

<?php
$money = 30;
$pet = "Kitten";
$new = sprintf("It costs $%3.2f for a %s.\n",$money,$pet);

$new2 = sprintf("%'.-20s%3.2f",$pet,$money) ."\n";
echo $new;

echo $new2;
$today = date("Y/m/d") ."\n";

echo $today;
?>

thank you kenrbnsn  and everyone. derek here is my corrected code. thanks.

 

<?php
$money = 30;
$pet = "Kitten";
$new = sprintf("It costs $%3.2f for a %s.<br>",$money,$pet);

$new2 = sprintf("%'.-20s%3.2f",$pet,$money) ."<br>";
echo $new;

echo $new2;
$today = date("Y/m/d") ."<br>";

echo $today;
?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.