Nissen
Nissen

Reputation: 287

How can I stop Wordpress from formatting 3 whitespace into 1?

I have a problem with Wordpress formatting my whitespaces, even though I don't want it to.

I have a dropdown with a bunch of options, one of them being:

Fighter 1110   8,5 kW

The 3 spaces between 1110 and 8,5 kW is very important for the API I'm sending it too, which was made by another company. The API creators insist that it should have 3 spaces for the API to work.

When I add

Fighter 1110   8,5 kW 

in the code, I can see when I inspect the page, that it has 3 spaces. But when i use rgpost() to get the value of the select, to send it to the API, it only has 1 space. I've tried to add 3   instead of normal space, but then if I var_dump() the string, it returns 'String(24) "Fighter 1110 8,5 kW"', but the string is only 21 long. I've then come to the conclusion that   counts as 2 instead of 1, which then makes it 24 instead of 21. So my question is:

How can I keep the 3 spaces, without using   ?

Upvotes: 2

Views: 55

Answers (1)

red
red

Reputation: 1629

Start by checkin into your database if the value is stored with one or three spaces. Do this to understand if the problems happen when your set the value or otherwise when you get

Next you can do the following:

  • Substitute the three spaces whit a pipe Fighter 1110|8,5 kW
  • When you need to submit the value replace back the pipe with the three spaces

The pipe is only an example, use what you want in place of pipe

Upvotes: 2

Related Questions