I want to create like a notepad in js and php
but I want it to add some spaces for each new line
I thought I can make it with a textarea, but I dont know how to
This is my idea:
<textarea name="text"></textarea>
and in PHP
$text = trim($_POST['text']);
$textAr = explode("\n", $text);
$textAr = array_filter($text, 'trim'); // remove any extra \r characters left behind
foreach ($textAr as $line) {
$height = $height + $line_height;
}
But not really sure it works. Any idea?
You are basically discarding the
explodestep. Try this instead:This basically allows any format of newline, and removes empty lines. You can then pass
$textArthroughforeach.