Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP

Juraj Ferenc
Juraj Ferenc
1,669 Points

php new line

Hello everyone I'm new into php and currently im taking PHP Basics course Well i encountered problem I dont know how to incorporate new line into for example my echos, i know that it was mentioned somewhere in course, but cant fin it. My basic code looks like

<html> <body> <?php $array_eyes = array( 'blue' , 'brown' , 'red'); print_r($array_eyes); //====Here i would like to have new line==== echo "Trying php with no success"; ?> </body> </html>

i tried to add <br> and \n like: print_r($array_eyes) "\n"; print_r($array_eyes) <br>;

but i always get error message. Any toughts please?

3 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 90,705 Points

Hi there.

You've got the escape sequence right.

<?php
$array_eyes =  array( 'blue' , 'brown' , 'red');
print_r($array_eyes) . echo "\n";
//====Here i would like to have new line====
echo "Trying php with no success";
?>

What you want to do is concatenate your string that contains the escape character. So the next thing you echo to the screen will appear on a new line. :-).

Bryan Manhollan
PLUS
Bryan Manhollan
Courses Plus Student 7,861 Points

If its in HTML, you'll have to do a <br> instead of a \n. Just something to keep in mind as well.

Juraj Ferenc
Juraj Ferenc
1,669 Points

Hey guys Thank you for your comments Can you please add how to do it into my code? I know that in html i have to use <br> but i don't know how to put it there :)

Juraj Ferenc
Juraj Ferenc
1,669 Points

Strange is that this forum ignore <b r> :). Wrote it in my previous post and system didn't display it.