I've got a list on a form that users can multiselect. All easy so far.

I pass that array to a new page through a query string.

My ISP has GLOBALS turned off, so...

How do I pass the $_POST["$querystring[]"] into another array so I can use it.

Primarily, I need to then implode it.

My code looks a bit like:

$newarray = $_POST["$querystring[]"];
$newstring = implode(",", $newarray);

But doesn't work, and neither does making $newarray into $newarray[].

Hope someone can help.

ironinthesoul.

    You can access the array normally, by
    $_POST['arrayname']['element']

      if the list in the form is called category, then do this on the form action page

      if the form method is POST use this print_r($_POST['category']);

      if it is GET use this print_r($_GET['category']);

      also make sure in the form u have defined the list in this way

      <select NAME="category[]" MULTIPLE="MULTIPLE">
      <option VALUE="1">Windows</option>
      <option VALUE="2">Linux</option>
      .
      .
      .
      .

      </select>
      reg
      kevin

        Thanks guys, but posting the array wasn't really the problem. It was doing something useful with it when it got to the next page.

        The real problem is feeding the array held in the $_POST into another variable (array) to use in the implode().

        How do you use the $_POST along with an implode()?

        I've now solved the problem by using Javascript to implode the string, feed the value in to a hidden field and then use the hidden field in the next page as it is already a string and not an aray.

        ironinthesoul

          I've now solved the problem by using Javascript to implode the string, feed the value in to a hidden field and then use the hidden field in the next page as it is already a string and not an aray.

          that probably isnt very secure.

          As I mentioned, you can treat the array as a variable, i.e.

          $_POST['array'] would be an array containing various elements that you can access as a 2d array.

            In other words:

            // Note: leave OUT the square brackets []...
            $array = $_POST['$yourvariable'];
            
            // $array is an array of the selections...
            // if you really need to implode it (seems silly to do so), do this:
            
            $mushedtogether = implode(",", $array);
            
            // otherwise, just access your values individually as needed:
            
            foreach ($array as $key => value) {
              // do something with $value, and with $key if needed...
            }
              Write a Reply...