hey there

i have a form where im trying to pass an array through to a page called "show_stats.php"... the array is called $games_found and im passing it as a hidden field

here is the form im using to pass the array:

echo "<table width='100%'  border='0'>";
		echo "<form method='post' action='show_stats.php'>";
		echo "<input type='hidden' name='year' value='$season'>";
		// if only 1 player was found, then send over the games he was found in, to speed up stats mining
		echo "<input type='hidden' name='games_found' value='$games_found'>";
		echo "<tr><td><div align='center'><input type='radio' name='mine_name' width='25%' checked='yes'
			value='$player_name'>$player_name</div></td></tr>";
		echo "<tr><td><div align='center'><input type='submit' name='show_stats' value='Show stats'></div></td></tr>";
		echo "<tr><td><div align='center'><a href='main.php'>Click here to search again</a></div></td></tr></table>";

this array contains 4 or 5 items usually.... but when i get the array in the "show_stats.php" page, it only contains 1 item.... and when i print the item out, it prints out as "A"

// get the games found   
$games_search = "{$_POST['games_found']}"; $number_of_games = count($games_search); print "$games_search[0] <br>"; // this prints out "A" for some reason print "$number_of_games <br>";

why is the array not being passed properly? and where is the "A" coming from?

any help would be greatly appreciated

    A is the first letter of the first element in the $_POST['games_found'] array

    you want:

    $games_search = $_POST['games_found'];

    not

    $games_search = "{$_POST['games_found']}";

      no, A isnt the first letter.... the array is full of integers, so if it was showing the 1st char of the 1st element, it would be a number

        get any result from the code change i did a test and it worked fine;

        $_POST['games_found']=array('aaaaaaa','bbbbbbbbbbbbb','cccccccccccccccc');
        
        $games_search1= "{$_POST['games_found']}"; 
        $games_search2 = $_POST['games_found']; 
        
        
        echo 'games_search1 = ' .$games_search1[0] ."<br>"; 
        echo 'games_search2 = ' .$games_search2[0] ."<br>"; 
        

        result:

        games_search1 = A
        games_search2 = aaaaaaa

          ok i get A fo the first one no matter what, but the other always works. A will be from array as its multid

            ok cool, ill try it out when i get a chance.... thanks for the help, it looks like you got it there ... ill let ya know

              Yup, because when you cast an array to a string (which is done to any variable being interpolated into a string) it becomes the string "Array". And the first (strictly, zeroth) letter of "Array" is.....

                Write a Reply...