473,386 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Splitting a name based on Capital letters

69
I have a username that is Joined together as follows
JohnSmith
The first letter in each of the first and last name is Capital
Can some one help me write a php function to split the name and get John Smith.
I am not sure what functions to use.
Dec 4 '07 #1
3 3070
here is the code [php]
<?php
function isuppercase($char)
{
if(ord($char)>64 && ord($char)<91)
{
return TRUE;
}
elseif(ord($char)>96 && ord($char)<123)
{
return FALSE;
}
else
{
return 'Non Alpha Character';
}
}

$string = 'JohsnSmithAndHisBrotherWentToLondon';
for($i=0; $i<strlen($string); $i++)
{

if( ($isupper = isuppercase($string{$i})) !== 'Non Alpha Character' )
{
if($isupper)
{
echo '<br>';
}
echo ' <strong>'.$string{$i}.'</strong> ';
}
else
{
echo 'Is not an alpha character';
}
}
?>[/php]
Dec 5 '07 #2
I have a username that is Joined together as follows
JohnSmith
The first letter in each of the first and last name is Capital
Can some one help me write a php function to split the name and get John Smith.
I am not sure what functions to use.
Or in one line like this:
[php]preg_replace('/[A-Z]/', ' $0', $text_tp_use);[/php]
Mar 23 '08 #3
satas
82
Or in one line like this:
[php]preg_replace('/[A-Z]/', ' $0', $text_tp_use);[/php]
Wow, that is awesome!
Mar 24 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Mark Light | last post by:
Hi, I have a string e.g. 'C6 H12 O6' that I wish to split up to give 2 strings 'C H O' and '6 12 6'. I have played with string.split() and the re module - but can't quite get there. Any help...
4
by: Carlos Marangon | last post by:
Hello! People go to sign my guestbook and wrote all text in capital letters. Did you know any script that shows an window alert when one types the second capital letter? Best regards,
3
by: Scott Navarre | last post by:
Hello, I have a javascript function that I want to read the name of the form which is calling it. Here is my HTML: <HTML> <HEAD> <SCRIPT LANGUAGE="JavaScript">
7
by: qwweeeit | last post by:
Hi all, I am writing a script to visualize (and print) the web references hidden in the html files as: '<a href="web reference"> underlined reference</a>' Optimizing my code, I found that an...
2
by: Gary Lynch | last post by:
I am looking for a simple solution to a recurrent problem with imported data in Access 97. The example below is a simplification of a problem with a much larger database. Let's say I start out...
3
by: RN | last post by:
I'm trying to fix user inputed names to proper case. People love to enter their names in all lower case or all upper, etc. I remember reading somewhere that there is an easy way in the framework...
5
Presto731
by: Presto731 | last post by:
HOW do i make the letters in various fields on a form always be capital no matter if they used capital letters or not when typing?
9
by: Meendar | last post by:
Hi, Below is my code snippet having only one form, <form> <input type ="radio" name="action" value="xyz" checked>xyz <input type ="radio" name="action" value="zyx">zyx <input type ="radio"...
12
by: kevineller794 | last post by:
I want to make a split string function, but it's getting complicated. What I want to do is make a function with a String, BeginStr and an EndStr variable, and I want it to return it in a char...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.