Nathaniel
Nathaniel

Reputation: 89

new line in string text

So i'm making something and i dont know how to make new line in php i've tried using nl2br but its giving me Template Error

Error

This is how it looks without new line

enter image description here

it says

Cadilab
AdministratorOnline

and it should be

Cadilab Administrator
Online

This is the code:

    echo '
<div id="profileview">
    <div class="cat_bar">
        <h3 class="catbg">
            <span class="ie6_header floatleft"><img src="', $settings['images_url'], '/icons/profile_sm.gif" alt="" class="icon" />', $txt['summary'], '</span>
        </h3>
    </div>

    <div class="covernebitno">
    <div class="avatar-profil"><a href="/index.php?action=profile">', $context['member']['avatar']['image'], '</a></center></div>
        <div class="usercover">
<div class="informacije">

<p>'.$context['member']['name'].'</br><span class="bojeipticice">'.nl2br((!empty($context['member']['group']) ? $context['member']['group'] : $context['member']['post_group']). '\r\n' .$context['member']['online']['text']) .'</p>
    <img src="http://i.imgur.com/U0TijfL.jpg" />

    <div class="covernebitno">

    </div></div>

            ';

Upvotes: 0

Views: 83

Answers (1)

Panda
Panda

Reputation: 6896

For this code, you can either use <br/><br/>:

<p>' . $context['member']['name'] . '</br><span class="bojeipticice">' . nl2br((!empty($context['member']['group']) ? $context['member']['group'] : $context['member']['post_group']) . '<br/><br/>' . $context['member']['online']['text']) . '</p>

OR use "\r\n" (enclosed with double quotes, instead of '\r\n'):

<p>' . $context['member']['name'] . '</br><span class="bojeipticice">' . nl2br((!empty($context['member']['group']) ? $context['member']['group'] : $context['member']['post_group']) . "\r\n" . $context['member']['online']['text']) . '</p>

Upvotes: 1

Related Questions