0

I am imploding an array. Instead of using a "," or other delimiter I would like two spaces.

How can this be accomplished?

I've tried:

<div>{implode("  ", $my_array)}</div> // Condenses to one space.
<div>{implode("&nbsp; &nbsp;", $my_array)}</div> // Just prints out the &nbsp. I do not use hashes in my code.

Note: I do NOT use the # in my nbsp. StackOverflow renders them as spaces if I don't :P

5
  • have you tried just &nbsp; and not &#nbsp; (if you don't use hashes in the code why do you paste it here) Commented May 14, 2013 at 2:55
  • Looks like you are using some kind of templating engine which is probably converting your &nbsp; to &amp;nbsp; check the documentation for "escape sequences" or "raw output". Commented May 14, 2013 at 2:56
  • The &nbsp; renders just fine now :) Commented May 14, 2013 at 3:00
  • What template engine are you using here? Commented May 14, 2013 at 3:00
  • 1
    Actually, your implode is working, but for HTML, multiple basic space will be rendered as a simple space, its a fact. That's why, there is the solution with "non-breakable space" also known as &nbsp;. You can also try to use some special tags like <pre> in order to keep the initial format. Commented May 14, 2013 at 3:01

2 Answers 2

1

try "\t" (a horizontal tab) or just "&nbsp &nbsp" (two html spaces)

Sign up to request clarification or add additional context in comments.

Comments

0

Actually, your implode is working, but for HTML, multiple basic space will be rendered as a single space, its a fact.

That's why, there is the solution with "non-breakable space" also known as &nbsp;.

You can also try to use some special tags like <pre> in order to keep the initial format

1 Comment

Pretty sure you meant "single space" and not "simple space".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.