Posted 26 July 2006 - 06:38 PM
For example, I have found that newlines entered into textareas and submitted via POST cannot be detected with
strpos($mystring, '\r\n'); or strpos($mystring, '\n');
but if I use the following code:
the newlines are detected!
How can these newlines be detected without actually explicitly defining a newline?
Posted 26 July 2006 - 07:12 PM
$text = "This has \n new line \r chars, \n and stuff"; $text = str_replace(array("\r", "\n"), '', $text); echo '<pre>' . $text . '</pre>';
Posted 26 July 2006 - 08:24 PM
Let's say I have a textarea as follows submitted with a carriage return in it-
When receiving the POST, I want to identify and replace the carriage returns entered into the form. The following code does not work:
str_replace("\r", '', $text);, str_replace("\n", '', $text);,
str_replace("\r\n", '', $text);
The above functions do not remove the newlines. If instead I use
as the string to replace, it works!
Posted 27 July 2006 - 02:26 AM
Posted 27 July 2006 - 09:55 AM
$foo = 'bar'; echo 'Hey I went to the $foo';You'll get this result:
Hey I went to the $foo
As you can see $foo hasnt been repleaced with its value when using single quotes. However if you use double quotes it'll parse the variable:
$foo = 'bar'; echo "Hey I went to the $foo";Which will now give you this result:
Hey I went to the bar
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users