Jump to content

Problem with using blank spaces as padding


ulterior

Recommended Posts

Hi, please bear with me - this may be an insanely simple problem, but its one that has stumped me so far.

 

So I'm developing a webapp, it reads results from a MySQL db, formats them into a string, publishes this as xml which is then sent via sms message. However the results need to be divided up so that sentences arent split across text messages - so my code adds x amount of underscore characters after a series of sentences in order to fill up the remaining 140 characters of a sms message (which then allows the next sentences to begin at the start of the next message).

 

So its sort of like "Sentence 1. Sentence 2 is long_____________________Sentence 3. Sentence 4. Sentence 5.______" (except across 140 characters). As produced by:

 

						$q = 0;
						while ($q <= $tofill)
						{
							$blank3 = $blank3 . "_";
							$q=$q+1;
						}

 

Anyway, my problem is that instead of underscores I want to use blank spaces. Again this is probably just a vast oversight on my behalf, but I havent been able to find a way to produce concurrent blank spaces in php. If I change

 

"$blank3 = $blank3 . "_";"

 

to

 

$blank3 = $blank3 . " ";

 

the spaces are collapsed, so instead of 16 underscores I get a single space. Is this just a stupid oversight on my behalf? Surely there is a way of putting multiple spaces into a string....?

Link to comment
Share on other sites

Well PHP shouldn't be messing with your spaces, they should remain intact. But a web browser will automatically turn a consecutive sequence of whitespace into 1 space on the screen. If you were to "View Source" for that page, you should see all of the whitespace intact. If you were noticing this problem after sending an SMS message, perhaps the system that processes the message automatically strips out extra whitespace. I'm not sure exactly how it works. Hope that helps.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.