473,786 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Splitting a name based on Capital letters

69 New Member
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 3092
chinmay4u
5 New Member
here is the code [php]
<?php
function isuppercase($ch ar)
{
if(ord($char)>6 4 && ord($char)<91)
{
return TRUE;
}
elseif(ord($cha r)>96 && ord($char)<123)
{
return FALSE;
}
else
{
return 'Non Alpha Character';
}
}

$string = 'JohsnSmithAndH isBrotherWentTo London';
for($i=0; $i<strlen($stri ng); $i++)
{

if( ($isupper = isuppercase($st ring{$i})) !== 'Non Alpha Character' )
{
if($isupper)
{
echo '<br>';
}
echo ' <strong>'.$stri ng{$i}.'</strong> ';
}
else
{
echo 'Is not an alpha character';
}
}
?>[/php]
Dec 5 '07 #2
subsquare
1 New Member
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 New Member
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
4293
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 would be greatly appreciated. Thanks,
4
10772
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
1549
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
2236
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 essential step is: splitting on a word (in this case 'href'). I am asking if there is some alternative (more pythonic...): # SplitMultichar.py
2
2096
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 with a single table, describing the colors of 4 national flags. I have 4 fields: Country Text 1stColor Text 2ndColor Text 3rdColor Text
3
1250
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 to convert name fields, first and last, to proper case. I forgot the name of that case syntax, but basically where you make sure to capitalize the first letter of someone's first and last name, fix all capital letters ("JOHN" > "john"), etc. ...
5
16992
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
1745
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" name="action" value="yxz">yxz </form>
12
1925
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 array. For example: char teststr; strcpy(teststr, "test:blah;");
0
9492
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10108
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4064
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.