Don P
Don P

Reputation: 63597

PHP: multiple spaces in PHP implode

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

Upvotes: 0

Views: 1277

Answers (2)

MatRt
MatRt

Reputation: 3534

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

Upvotes: 0

vijrox
vijrox

Reputation: 1156

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

Upvotes: 1

Related Questions