Changing to a string to Title Case

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
j2ee
Forum Newbie
Posts: 5
Joined: Tue Jun 08, 2010 10:18 am

Changing to a string to Title Case

Post by j2ee »

I found that php has it's own built in function for this I just can't figure out where to put it. I have a form with a couple specific fields that I would like to process with this and so far I figured I would put it in the value field:

Code: Select all

<tr>
			<td colspan="2" height="13">&nbsp;</td>
		</tr>
		<tr>
			<td align="right"><span class="red">*</span> Last name:&nbsp;</td>
			<td><div style="float:left">
					<input name="lastName1" type="text" size="45" id="lastName1" maxlength="60" value="<?=$lastName1=ucfirst(strtolower($lastName1)),$_POST['lastName1']?>" />
					</div></td>
		</tr>
My only worry is that there is no:

Code: Select all

firstName1=$firstName1
anywhere in the form, and where would I put it?
j2ee
Forum Newbie
Posts: 5
Joined: Tue Jun 08, 2010 10:18 am

Re: Changing to a string to Title Case

Post by j2ee »

or would it work like this without the $:

Code: Select all

	
<tr>
	<td align="right"><span class="red">*</span> First name:&nbsp;</td>
	<td><input name="firstName1" type="text" size="45" id="firstName1" maxlength="60" value="<?=firstName1=ucfirst(strtolower(firstName1))?><?=$_POST['firstName1']?>" /></td>
	</tr>
Post Reply