Letting a new PHP page know a new POST value is an Array?

Posted by Wintermute on Stack Overflow See other posts from Stack Overflow or by Wintermute
Published on 2010-03-24T16:32:55Z Indexed on 2010/03/24 16:43 UTC
Read the original article Hit count: 292

Filed under:
|
|
|
|

I have a page that creates an associative array, then passes it as a hidden value to a new PHP page. I have a foreach loop waiting to iterate through it but it coughs up an "invalid argument" error, as if the page doesn't know the value it's working with is an array (Despite "print" showing simply "Array"). This is essentially what I have:

//Hidden input to be passed to the next page
print "<input type=\"hidden\" name=\"price_list\" value=\"$item_list\">


//Code on the second page for the foreach loop
extract($_POST);
foreach($price_list as $name=>$price) {
...
}

But I am simply given "Warning: Invalid argument supplied for foreach() in /home/cut/mg299/public_html/PHP/invoice.php on line 17". The array works fine, as I can iterate on the previous page, and other values are parsed fine to this second page.

Do I need to 'reinitialise' this array value?

© Stack Overflow or respective owner

Related posts about php

Related posts about array