Forum Moderators: coopster

Message Too Old, No Replies

How can arrays be dynamic with user and administrative input.

         

Flolondon

10:51 am on Mar 26, 2006 (gmt 0)

10+ Year Member



hello

Can someone please show me how by examples - how scalar and associatie arrays can be dynamic with the user and administrative imput.

jatar_k

6:04 pm on Mar 26, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



can you explain what you are trying to do a little more? I have no idea how to answer.

Flolondon

6:33 pm on Mar 26, 2006 (gmt 0)

10+ Year Member



I am trying to understand what is so special about the use of arrays when the output could just as well be written in HTML.

I am trying to understand the dynamical function of arrays with regards to user input.

Flolondon

7:54 pm on Mar 26, 2006 (gmt 0)

10+ Year Member



<form action="buy_snacks.php" method="post">
<select multiple name="snacks[ ]">
<option value="coke">CocaCola</option>
<option value="popcorn">Popcorn</option>
<option value="peanuts">Peanuts</option>
</select>
</form>


<?php
$snacks = $_POST['snacks'];
// Note that $snacks will be an array.
foreach ($snacks as $s) {
echo "$s<br />";
}
?>

for the above example it would just output
Cola cola, popcorn and peanuts.

wouldnt it be easier to just write it in HTML