jeff5656 Posted September 14, 2009 Share Posted September 14, 2009 Hello, Lets say I have a form and I want to pre-populate a field: Last Name:<input type="text" size="12" name="lname" value="<?php echo $_GET['pt'];?>"/> Now what if this is the patient's name and I want to only put in their last name? Smith, Christopher IS there a command to take GET['pt'] and only use all the characters UP TO the comma (and exclude the comma)? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/174239-use-only-part-of-a-getid-value/ Share on other sites More sharing options...
rhodesa Posted September 14, 2009 Share Posted September 14, 2009 Last Name:<input type="text" size="12" name="lname" value="<?php echo substr($_GET['pt'],0,strpos($_GET['pt'],','));?>"/> Quote Link to comment https://forums.phpfreaks.com/topic/174239-use-only-part-of-a-getid-value/#findComment-918515 Share on other sites More sharing options...
wshell Posted September 14, 2009 Share Posted September 14, 2009 Use Split(str pattern, str string) $name = "John, Doe"; $splitName = split(",",$name); Now $splitName would be an array with 2 values.. $splitName[0] = "John" $splitName[1] = "Doe" so to get just the first name echo out $splitName[0]; cheers... Quote Link to comment https://forums.phpfreaks.com/topic/174239-use-only-part-of-a-getid-value/#findComment-918518 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.