PHP: Line break and strpos
Question by Compi | 2012-06-20 at 21:41
I am at a loss. I want to find the position of a line break within a string using strpos() in PHP. Up to now, I have already experimented with:
strpos($string,'\n');
But somehow, it does not seem to be working. Now, I am even thinking about using nl2br() to get to the breaks in some way, but that is nevertheless far too complicated and with this solution, you should not ask for the performance anyway.
Thus, maybe someone knows how to do that?
Related Topics
Rewrite Text Files with a fixed Line Length
Tutorial | 0 Comments
Repair Text Files with mixed Line Breaks
Tutorial | 0 Comments
How to Replace multiple Texts at the same Time
Tutorial | 0 Comments
How to resize Image before Upload in Browser
Tutorial | 13 Comments
Delphi: Multiline Caption for TLabel (at Run Time and Design Time)
Tutorial | 1 Comment
jQuery: Assign Action to Keyboard Keys (Keyboard Event)
Tip | 0 Comments
HTML Form: Redirection depending on Radiobutton or Checkbox State
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
Certainly, your approach is not that bad. But you have to use double instead of single quotes:
Otherwise, PHP interprets the \n not as a line break but as the characters "\" and "n".
PS: And please, forget about the nl2br() solution quickly... ;)
2012-06-21 at 15:29