Jump to content

array info


AL123

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.