Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

pad every alternate character with a space

Posted on 2008-06-25
2
Medium Priority
?
260 Views
Last Modified: 2010-04-21
Hi

$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
0
Comment
Question by:Neil Thompson
2 Comments
 
LVL 34

Accepted Solution

by:
Beverley Portlock earned 2000 total points
ID: 21865604
This should do it

$myString = "BA5DSH1BXA5Q";

echo ereg_replace("(.{1})", "\\1 ", $myString );
     
0
 
LVL 3

Author Closing Comment

by:Neil Thompson
ID: 31470539
ta
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question