Jump to content

how to store value from a array into one variable?


Recommended Posts

hello, um i got a form that stored an array of variables upon users clicks.

it submits to another page fine as an array and i can print them using

if(!empty($_POST['langSpoken'])) {

    echo "\n<p><strong>You selected the following LangSpoken:</strong></p>\n<ul>";

    foreach($langSpoken as $lang) {

      // exclude any items with chars we don't want, just in case someone is playing
      if(!preg_match('/^[-A-Z0-9\., ]+$/iD', $lang)) continue;

      // print the lang
      echo "\n\t<li>" . htmlspecialchars($lang) . "</li>";
    echo "\n</ul>";

  else {
    echo "\n<p>No items selected</p>";


it prints a list a of array like

  • english
  • spanish


but i need to store each one in one variable so i can store in a database

is there a way?


Link to comment
Share on other sites

You don't want to store all the values in one record within the database, that would be a poor design decision. Instead, each of these values should have there own row. You can then use another items 'id' to relate them if need be.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.