Page 1 of 1

Variable disaper

Posted: Thu Jan 21, 2010 3:36 am
by taly
In the script below I cannot figure out why my $test_array is gone after line 16

Please give me a hint to solve this problem

Code: Select all

<?php
 
$test_array = array(1,2,3,4);
 
// Here I can see the $test_array
echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="testing">';
// echo "<select name='test'>";
 
print_r($test_array); Display: Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 ) 
 
echo "<br>";
echo "<br>";
 
// Here I cannot see the $test_array
echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="testing">';
echo "<select name='test'>";
 
print_r($test_array); Display: Nothing
 
?>

Re: Variable disaper

Posted: Thu Jan 21, 2010 3:41 am
by John Cartwright
Nothing? Are you sure it's not displayed in the source code? Considering your outputting it inside a <select> tag I doubt it would show up on screen.

If not, what does var_dump() say..