Jump to content

[SOLVED] array help .. part 1


imarockstar

Recommended Posts

I was wandering how to print out and echo this array .... what I have seems not to work ...

 

my code :)

 

<?php


if ( $_POST['submit'] )
{

$keys = array_values(array_keys($_POST));
    $values = array_values($_POST);

echo $values[$text1]; 
   



}





?>



<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" ?>

field 1 : <input name="mytext[text1]" size="20" > <br>
field 2 : <input name="mytext[text2]" size="20" > <br>
field 3 : <input name="mytext[text3]" size="20" > <br><br>
<input type="submit" name="submit" value="test">

</form>

 

Link to comment
https://forums.phpfreaks.com/topic/166101-solved-array-help-part-1/
Share on other sites

<?php
if ( $_POST['submit'] )
{
   foreach($_POST['mytext'] as $key=>$value){
      echo "$key: $value<br />";
   }      
}
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" ?>
field 1 : <input name="mytext[text1]" size="20" > <br>
field 2 : <input name="mytext[text2]" size="20" > <br>
field 3 : <input name="mytext[text3]" size="20" > <br><br>
<input type="submit" name="submit" value="test">
</form>

Archived

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.