Solved

pad every alternate character with a space

Posted on 2008-06-25
2
225 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 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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 dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

808 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