user2894908
user2894908

Reputation:

Split String into two lines in php

I have a String variable and I need it to be printed in two lines. This is my String.

$send = "Thank you for registering. For more details contact us";

I need this string to be printed like this

Thank you for registering. 
For more details contact us

I tried like this

 $send = "Thank you for registering.<br/> For more details contact us";

But it printed this:

 Thank you for registering.<br/> For more details contact us

How do I print this as I needed?

Thank you!

Upvotes: 1

Views: 111

Answers (5)

Amare
Amare

Reputation: 715

Try as the below code.

$send = "Thank you for registering with Playit. \n If you have any questions please contact [email protected].";

Upvotes: 0

Amit Kumar Sahu
Amit Kumar Sahu

Reputation: 495

if you want to text in a text area you can try this

 $send = "Thank you for registering.&#13; For more details contact us";
 <textarea>
 <?php echo $send; ?>
 </textarea>

Upvotes: 1

Umair Ayub
Umair Ayub

Reputation: 21231

To display that String in HTML

$send = "Thank you for registering.<br/> For more details contact us";

And for plain text files

$send = "Thank you for registering.\n For more details contact us";

Upvotes: 0

Subodh Ghulaxe
Subodh Ghulaxe

Reputation: 18651

<?php $send = "Thank you for registering.\n For more details contact us"; ?>

If you want to print in textarea or email you can use

 <textarea>
    <?php echo $send; ?>
 </textarea>

If you want to print as HTML, try

<?php echo nl2br($send); ?>

Upvotes: 2

FortMauris
FortMauris

Reputation: 167

$send = "Thank you for registering.<br/> For more details contact us";
echo $send;

This shouldn't be an issue if you're using echo. If this doesn't works, try this:

$send = "Thank you for registering.\n For more details contact us";

Hope it helps.

Upvotes: 2

Related Questions