Jump to content

Lost with PHP


Guest cfican

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...