Drags111 Posted November 11, 2007 Share Posted November 11, 2007 Ok i have this html form here: http://www.gma.asssoft.org/register.html and its action is to go to a php file. In the php file I want it to take the first letter of the first name, and add it to the last name to combine one string. Example: You enter: John Doe then the script turns it to jDoe. Possible? Quote Link to comment Share on other sites More sharing options...
MadTechie Posted November 11, 2007 Share Posted November 11, 2007 i guess you could do this $name = "John Doe"; $name = preg_replace('/(\w)\w+\s(\w+)/', '\1\2', $name ); Quote Link to comment Share on other sites More sharing options...
AndyB Posted November 11, 2007 Share Posted November 11, 2007 Possible? Of course. <?php $fname = strtolower($_POST['fname']); $answer = $fname{1}. $_POST['lname']; ?> Quote Link to comment Share on other sites More sharing options...
Drags111 Posted November 11, 2007 Author Share Posted November 11, 2007 i love you andy Quote Link to comment Share on other sites More sharing options...
Drags111 Posted November 11, 2007 Author Share Posted November 11, 2007 but how do u combine the strings to be jDoe? Quote Link to comment Share on other sites More sharing options...
AndyB Posted November 11, 2007 Share Posted November 11, 2007 That code does. Or at least it would if I'd specified the zeroth element of the array ... $fname{0} ... the dot in the code is the concatenation operator, i.e. it adds the two strings together. Quote Link to comment Share on other sites More sharing options...
Drags111 Posted November 11, 2007 Author Share Posted November 11, 2007 yah i actualy have to put it at fname{0} to make it come out as jDoe. otherwise {1} will make it come as oDoe Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.