Page 1 of 1
space
Posted: Wed Sep 03, 2003 6:29 pm
by nincha
any tips to show space character thats from Mysql
Posted: Wed Sep 03, 2003 7:59 pm
by volka
please explain in more detail.
Posted: Wed Sep 03, 2003 8:31 pm
by JAM
Like this?
Code: Select all
<?php
$result = count_chars("You mean something like this?",0);
// 32 being the code for space...
echo $result[32]; // returns 10
?>
Posted: Thu Sep 04, 2003 12:46 am
by nincha
what i meant is that, when somthing like this is saved into Mysql
"my name is bob _____ , look at those spaces _______ when i retrieve this string from Mysql the blank spaces will not show." the lines represent blank spaces.
Posted: Thu Sep 04, 2003 12:58 am
by Drachlen
That's because by default anything beyond ' ' will be removed.. So what you can do is add this right before you insert it:
Code: Select all
$_POST['text'] = str_replace(" ","&*nbsp;",$_POST['text']);
This will modify it so that all those spaces and changed into &*nbsp; which is a space, but it doesn't get removed.
Be sure to remove the star between "&" and "nbsp;" i added it so that it was visible
Posted: Thu Sep 04, 2003 12:05 pm
by phice
That's a smart idea, but that would turn ALL spaces in your text into a straight line. Try it with a very long message, and you'll see what I mean.
Posted: Thu Sep 04, 2003 6:49 pm
by JAM
But it does the thing...

wordwrap() it?
Posted: Thu Sep 04, 2003 10:56 pm
by phice
If there are more spaces than normal, I might try either wordwrap or something like:
Code: Select all
str_replace(" ", " &*nbsp;", $string);
But then again, I've never tried it..
Space
Posted: Mon Sep 15, 2003 3:29 am
by tazque
Hv U try this;
$text = trim($text)
Posted: Mon Sep 15, 2003 3:36 am
by JayBird
trim will only strip whitespace from the begining and end of a string.
http://se.php.net/manual/en/function.trim.php
Mark