Jump to content

Recommended Posts

newbee Question: I can't get my info out of the array unless

I use print_r(). echo or print just returns the word Array.

Thanks - AL123

 


function pro_form() //process the form
{
echo "test, " . $_POST['test'] . " Done";
}

function display_form($errors = '') //display the form
{
if($errors)
	{
		echo $errors;
		print_r($errors);
	}
echo "<form method='post' action='$_SERVER[php_SELF]' > 
	test: <input type='text' name='test'>
	      <input type='submit' value='TEST'>
          <input type='hidden' name='submit_check' value='1'>
	  </form>" ;
}

function validate_form() //pass errors to display_form
{
if(strlen($_POST['test']) < 3) 
	{
	$errors[] = 'Whatever you post must be 3 chars long';
	}
if(strlen($_POST['test']) > 
	{
	$errors[] = 'Whatever you post must be less than 8 chars long';
	}
return $errors;
}

if(array_key_exists('submit_check', $_POST))
{
if($form_errors = validate_form())
	{
	display_form($form_errors);
	}
else
	{
	pro_form(); 
	}
}
else
{
display_form();
}

Link to comment
https://forums.phpfreaks.com/topic/186407-array-info/
Share on other sites

try

echo "Array Value 1: " . $errors[0] . "<br />";
echo "Array Value 2: " . $errors[1] . "<br />";
echo "Array Value 3: " . $errors[2] . "<br />";
echo "Array Value 4: " . $errors[3] . "<br />";
echo "Array Value 5: " . $errors[4] . "<br />";
echo "Array Value 6: " . $errors[5] . "<br />";
echo "Array Value 7: " . $errors[6] . "<br />";
echo "Array Value 8: " . $errors[7] . "<br />";

 

thats bout the easiest way I can sum it up, as I can't think well right now under slept over worked ahh the life of a coder...

Link to comment
https://forums.phpfreaks.com/topic/186407-array-info/#findComment-984367
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.