• Resolved onethousandseas

    (@onethousandseas)


    Hi, I”m trying to format results on my search results page in a specific way. Right now it looks like this:

    <?php
    if($post->post_type == 'post') {
    echo the_time('Y');
    echo the_time('M');
    echo the_time('j');
    echo the_time('H:i');
    }
    else {print "Page";}
    ?>

    How can I format it with line breaks to look like this?

    <?php
    if($post->post_type == 'post') {
    echo the_time('Y'); [NEWLINE]
    echo the_time('M'); [NEWLINE]
    echo the_time('j'); [NEWLINE]
    echo the_time('H:i');
    }
    else {print "Page";}
    ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • <?php
    if($post->post_type == ‘post’) {
    echo the_time(‘Y’).”
    “;
    echo the_time(‘M’).”
    “;
    echo the_time(‘j’).”
    “;
    echo the_time(‘H:i’).”
    “;
    }
    else {print “Page”;}
    ?>

    https://www.coimbatoreindia.co.in

    echo the_time('Y')."<br />"; could do the trick.

    Peter

    echo
    the_time('Y').'<br />'.
    the_time('M').'<br />'.
    the_time('j').'<br />'.
    the_time('H:i');

    No need to echo, echo, echo, echo..

    Unless of course you’re referring to \n aka new line..

    Thread Starter onethousandseas

    (@onethousandseas)

    Thank you all!

    Here’s the final code I used:

    <?php
    if($post->post_type == 'post') {
    echo the_time('Y')."<br />";
    echo the_time('M')."<br />";
    echo the_time('j')."<br />";
    echo the_time('H:i')."<br />";
    }
    else {print "Page";}
    ?>

    Marking it resolved!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘New line break in PHP?’ is closed to new replies.