Guest cfican Posted December 13, 2006 Share Posted December 13, 2006 The variable $fname builds from the array value in $_POST just fine, until I exit the for loop. Then it is gone. global $lname, $fname;$lname = "";$fname = ""; for ($i=1; $i<strlen($_POST['emp_1']); $i++) { if (substr($_POST['emp_1'],$i,1) != " ") { $fname = substr($_POST['emp_1'],0,$i); } else { $fname = substr($_POST['emp_1'],0,$i); exit; } }echo $fname . "<br>"; echo $fname; shows nothingwhen the line is placed just above the exit, it's value shines through. What am I doing wrong? Link to comment Share on other sites More sharing options...
aspnetguy Posted December 13, 2006 Share Posted December 13, 2006 echo the result of this strlen($_POST['emp_1']) is it greater than 0? Link to comment Share on other sites More sharing options...
Guest cfican Posted December 13, 2006 Share Posted December 13, 2006 echo the result of this strlen($_POST['emp_1']) is it greater than 0?Yes, it is 13. Mid way there is a space. It is a name, six characters space six characters. Link to comment Share on other sites More sharing options...
Guest cfican Posted December 13, 2006 Share Posted December 13, 2006 I hade an exit statement where I should have had a break. Problem solved. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now