• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

pad every alternate character with a space


$myString = "BA5DSH1BXA5Q";

I want to pad every character with a space, so BA5DSH1BXA5Q
would become B A 5 D S H 1 B X A 5 Q

How can I do this please
Neil Thompson
Neil Thompson
1 Solution
Beverley PortlockCommented:
This should do it

$myString = "BA5DSH1BXA5Q";

echo ereg_replace("(.{1})", "\\1 ", $myString );
Neil ThompsonSenior Systems DeveloperAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now