Jump to content

Recommended Posts

Hi all long time since i been here hope everyone is keeping cool

 

so it has come to me lately that i should be able to do this but cant figure out how

what i am trying to do is use the $_Post array in a way so i can auto generate forms on the flybut i need to be able to do one thing i cant figure out which is how to do

1 echo the variable identifier

that's it and what i mean is

say i had a input called "name"

 

now what i want to be able to do is something like this

echo "my". <Missing bit> ." is ". $_POST['name'];

which in the public say something like

my name is bob

 

now this is probably a very simple thing to do and if anyone knows i would be very grateful

Link to comment
https://forums.phpfreaks.com/topic/153159-_post-identifier/
Share on other sites

Are you looking for something like this?:

 

<?php
$str = 'name';
echo "my $str is " . $_POST[$str];
?>

 

Or you could loop through the post array like this, getting access to both keys and values:

 

<?php
foreach ($_POST as $key => $value) {
   echo "The value associated with the key '$key' is '$value'.<br />";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/153159-_post-identifier/#findComment-804519
Share on other sites

<?php
foreach ($_POST as $key => $value) {
   echo "The value associated with the key '$key' is '$value'.<br />";
}
?>

 

thank you this is exactly what i was after so thank you

 

are you able to explain this code at all tho in terms of how it works

$_POST as $key => $value

Link to comment
https://forums.phpfreaks.com/topic/153159-_post-identifier/#findComment-804628
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.