Solved

Is there a "preg replace" or something similar that will insert spaces between lc letters & uc letters?

Posted on 2013-06-30
2
364 Views
Last Modified: 2013-06-30
Hi Guys,
An external database that I have no access or control of is returning proper names in the following format "FirstLast" instead of "First Last".
I need to put a space between the First and Last names without losing the initial caps.
I think there may be a "preg_replace" type of solution for this problem but I don't know what it is. Can you help?
Thanks,
Sas
0
Comment
Question by:sasnaktiv
2 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39288632
Haven't tested this too much but seems to work

<?php
$name="FirstLast";

echo preg_replace('/([a-z])([A-Z])/', "$1 $2", $name);

Open in new window

0
 
LVL 1

Author Closing Comment

by:sasnaktiv
ID: 39288937
Hey Gary,
It definitely does work!
Thank you.
Thank you.
Thank you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

932 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now