'How to split TextArea Input at every line break PHP
i have some trouble splitting my TextArea Input at every linebreak: If I insert this text:
"Hello:
world"
Then I have this string as my value
Hello: world
I tried something like
$input = str_replace(" ", "", $input);
OR
$input = trim($input);
But nothing changes.
I want to remove all the linebreaks because later when I output the string with htmlspecialchars it fills the line breaks with something like " &#";
And I want to remove it.
So I thought i can split the string and after that, add it up together so all my linebreaks will be removed.
Solution 1:[1]
You can use :
$input = str_replace(["\r", "\n"], '', $input);
Or
preg_replace("/\r|\n/", "", $input);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Wahyu Kristianto |
