0

I want to add Line break in a textarea placeholder using php.

Code:

<!DOCTYPE html>
<html style="height: 100%;">

<head>
  //stuff
</head>

<body>
  //stuff
  <div id="editContainer">
      <textarea id="note" name="note" placeholder="Placeholder Text"></textarea>
  </div>
  //stuff
</body>
</html>
cash.io.co
  • 13
  • 5

1 Answers1

0

This Should Work:

<textarea placeholder="<?php
$data = 'Line Number One,-,Line Number Two';
$ndata = str_replace(',-,',"\n",$data);
print "$ndata"; ?>"></textarea>

You can change the ,-, in the third line to anything that suits you.

Here's some pointers:

  • Make sure you rename your file to .php
  • Make sure you use a local server or online server to parse the code.
  • HTML Comments are Written as <!--Comment--> not as //comment(that's JavaScript)
Akaanksh Raj
  • 126
  • 1
  • 9