jesushax Posted April 21, 2009 Share Posted April 21, 2009 hi all the below is copied from my source 12345687 if you copy it then start deleteing after 4 deletes it jumps like a tab space, but i tired a str_replace to remove the tab spacing didnt work function NoSpaces($text) { $text = str_replace(" ","",$text); return $text; } Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/ Share on other sites More sharing options...
Mchl Posted April 21, 2009 Share Posted April 21, 2009 Try removing \t (that's backslash+t). It's escape sequence for tab. Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815314 Share on other sites More sharing options...
jesushax Posted April 21, 2009 Author Share Posted April 21, 2009 no still didnt work, could it be something else not a tab? Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815316 Share on other sites More sharing options...
Mchl Posted April 21, 2009 Share Posted April 21, 2009 Perhaps you could just use trim? Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815317 Share on other sites More sharing options...
jesushax Posted April 21, 2009 Author Share Posted April 21, 2009 yeah i did, but trim only removes 1 trailing and leading space doesnt it that example text has 4 spaves and some wierd tab:| i tried both no luck $text = trim($text); $text = str_replace("\t","",$text); Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815320 Share on other sites More sharing options...
jesushax Posted April 21, 2009 Author Share Posted April 21, 2009 right ive just copied that dodgy text into a page now and im trying everything to get rid of it i even copied and pasted the whole gap into the str_replace and that didnt work :| <?php $data = "12345687 "; str_replace(" ","",$data); echo $data; ?> Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815336 Share on other sites More sharing options...
Yesideez Posted April 21, 2009 Share Posted April 21, 2009 Are you saying there's spaces/tabs/something on the end of the numbers or something appearing above/below them as well? Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815341 Share on other sites More sharing options...
kenrbnsn Posted April 21, 2009 Share Posted April 21, 2009 This <?php $data = "12345687 "; str_replace(" ","",$data); echo $data; ?> willl not work, since you don't change the value of $data. This <?php $data = "12345687 "; $data = str_replace(" ","",$data); echo $data; ?> or <?php <?php $data = "12345687 "; $data = str_replace("\t","",$data); echo $data; ?> Should. Ken Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815344 Share on other sites More sharing options...
jesushax Posted April 21, 2009 Author Share Posted April 21, 2009 ah yes, whoops my bad i knew that the /t worked seems it was a tab after all Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815347 Share on other sites More sharing options...
jesushax Posted April 21, 2009 Author Share Posted April 21, 2009 what is a space in the same format as the /t for tab Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815353 Share on other sites More sharing options...
kenrbnsn Posted April 21, 2009 Share Posted April 21, 2009 There is no special representation for a space. And its "\t", not "/t" for a tab. For a complete list see this section in the manual. Ken Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815356 Share on other sites More sharing options...
jesushax Posted April 21, 2009 Author Share Posted April 21, 2009 hmm well the text seems to still have some sort of spacing character in there <?php $text = "12345687 "; $text = str_replace("\t","",$text); $text = str_replace(" ","",$text); $text = str_replace(" ","",$text); $text = str_replace(" ","",$text); $text = str_replace(" ","",$text); $text = str_replace(" ","",$text); $text = str_replace(" ","",$text); $text = str_replace(" ","",$text); echo $data; ?> gives me the below the tabs gone but theres still spacing if you highlight it, what can this spacing be? 12345687 Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815360 Share on other sites More sharing options...
Yesideez Posted April 21, 2009 Share Posted April 21, 2009 $len=strlen($text); for ($i=0;$i<$len;++$i) { echo 'Position '.$i.':'.ord($text[$i]).'<br>'; } Run that and post the output - I'd LOVE to know what those spaces are. Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815362 Share on other sites More sharing options...
jesushax Posted April 21, 2009 Author Share Posted April 21, 2009 it gave back this Position 0:49 Position 1:50 Position 2:51 Position 3:52 Position 4:53 Position 5:54 Position 6:56 Position 7:55 what does this mean? Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815364 Share on other sites More sharing options...
Yesideez Posted April 21, 2009 Share Posted April 21, 2009 Now look those values up in an ASCII chart 49=1 50=2 51=3 52=4 53=5 54=6 56=8 55=7 I was hoping the space(s) would show up or are you passing it the trimmed string? It needs to be passed the string with the spaces on the end. Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815367 Share on other sites More sharing options...
Daniel0 Posted April 21, 2009 Share Posted April 21, 2009 What exactly are you trying to do? You can do $string = preg_replace('#\s#', '', $string); to replace all whitespace (tabs and spaces included). Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815369 Share on other sites More sharing options...
jesushax Posted April 21, 2009 Author Share Posted April 21, 2009 well heres the code that make this happen form data goes to register.php register.php $_SESSION["PostData"] = $_POST; so i can recall the form data if the users gets redirected becuase of an errror, eg. they havent put in a required field so when the user is redirected back to regform regform.php $post = $_SESSION["PostData"]; <input name="Sect1_6" type="text"size="30" value="<?php echo NoSpaces($post["Sect1_6"]); ?> " <?php if($error == "email") { echo 'style="border:1px solid #FF0000;"'; } ?> /> no spaces function function NoSpaces($text) { $text = str_replace("\t","",$text); $text = str_replace(" ","",$text); $text = str_replace(" ","",$text); $text = str_replace(" ","",$text); $text = str_replace(" ","",$text); $text = str_replace(" ","",$text); $text = str_replace(" ","",$text); $text = str_replace(" ","",$text); return $text; } and in that field i have the value 12345687 which has those wierd spaces trailing it, we got rid of the tab not theres these smaller spaces that look just like spaces but there not? Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815375 Share on other sites More sharing options...
Daniel0 Posted April 21, 2009 Share Posted April 21, 2009 Read my reply above. Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815376 Share on other sites More sharing options...
jesushax Posted April 21, 2009 Author Share Posted April 21, 2009 i tried that, it didnt get rid of any of them :| also that would remove space if a user has put space between a word which we need to keep Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815382 Share on other sites More sharing options...
Yesideez Posted April 21, 2009 Share Posted April 21, 2009 What does strlen() result in giving on the string WITH spaces? Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815384 Share on other sites More sharing options...
jesushax Posted April 21, 2009 Author Share Posted April 21, 2009 awww bloody hell im such an idiot lol it was working just my code for my form field... i had it like <input name="Sect1_5" type="text" size="15" value="<?php if($action == "edit") { echo $row["Sect1_5"]; } else { echo NoSpaces($post["Sect1_5"]); } ?> " /> leaving spaces after the value has been posted, god dammit lol sorry for wasting your time :| sowiiiiiii! THanks Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815391 Share on other sites More sharing options...
Yesideez Posted April 21, 2009 Share Posted April 21, 2009 LOL It happens to all of us at some time Quote Link to comment https://forums.phpfreaks.com/topic/155013-solved-whats-this-white-space-like-a-tab-but-not/#findComment-815392 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.