Php $_GET issue

foreach ($_GET as $field => $label)
{
   $datarray[]=$_GET[$field];
   echo "$_GET[$field]";
   echo "<br>";
}
print_r($datarray);

This is the output I am getting. I see the data is there in datarray but when I echo $_GET[$field]

I only get "Array"

But print_r($datarray) prints all the data. Any idea how I pull those values?

OUTPUT
Array ( 
        [0] => Array ( 
                 [0] => Grade1 
                 [1] => ln 
                 [2] => North America 
                 [3] => yuiyyu 
                 [4] => iuy 
                 [5] => uiyui 
                 [6] => yui 
                 [7] => uiy 
                 [8] => 0:0:5 
                 ) 
)

Answers


EDIT: When I completed your test, here was the final URL:

http://hofstrateach.org/Roberto/process.php?keys=Grade1&keys=Nathan&keys=North%20America&keys=5&keys=3&keys=no&keys=foo&keys=blat&keys=0%3A0%3A24

This is probably a malformed URL. When you pass duplicate keys in a query, PHP makes them an array. The above URL should probably be something like:

http://hofstrateach.org/Roberto/process.php?grade=Grade1&schoolname=Nathan&region=North%20America&answer[]=5&answer[]=3&answer[]=no&answer[]=foo&answer[]=blat&time=0%3A0%3A24

This will create individual entries for most of the fields, and make $_GET['answer'] be an array of the answers provided by the user.

Bottom line: fix your Flash file.


Use var_export($_GET) to more easily see what kind of array you are getting.

From the output of your script I can see that you have multiple nested arrays. It seems to be something like:

$_GET = array( array( array("Grade1", "ln", "North America", "yuiyyu", "iuy", "uiyui", "yui","uiy","0:0:5")))

so to get those variables out you need something like:

echo $_GET[0][0][0]; // => "Grade1"

Need Your Help

Can I use iconv to convert multi-byte smart quotes to extended ASCII smart quotes?

php character-encoding iconv extended-ascii

I have some UTF-8 content that includes multi-byte smart quote characters. I've found that this code will easily convert those characters to ASCII straight quotes (ASCII code 34):

Unit Testing basic Controllers

unit-testing zend-framework phpunit code-coverage

I have a number of simple controller classes that use Doctrine's entity manager to retrieve data and pass it to a view.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.