![]() |
Telling the difference between space bar and return key
Code:
$_POST['xtraimg'] = trim(preg_replace('#\s+#si', ' ', $_POST['xtraimg'])); The above code strips all spaces completely out, only leaving one like it should. However it removes spaces for paragraphs also. Is there a way a code can tell the difference between a spacebar space and a return/enter key newline/space? |
code looks better now
|
you can probably use a class of characters instead of \s if you don't want \n (newline) to be matched.
try using [\x20] instead of \s if you just want to match spaces. so, your code would look like Code:
$_POST['xtraimg'] = trim(preg_replace('#[\x20]+#si', ' ', $_POST['xtraimg'])); |
cool, thanks
I'll give it a shot! edit: I found a use for this in vb also |
heh, relooking at my code... you don't need the braces ['s ]'s
\x20+ will work just fine too... don't know what I was thinking ;) |
All times are GMT. The time now is 09:13 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|