Jump to content

Catching variables


Perfidus

Recommended Posts

Hi there!

 

I have a bunch of vars like tipo1, tipo2, tipo3, tipo4 sent via POST...

The number may vary depending on user choice.

I would like to recover the vars in an array, but the way I'm trying is not working:

 

for($i=0;$i<$numberoftipos;$i++)
{
$tipo2=array($tipo[$i]);
echo $tipo2[$i]."<br>";
}

 

It echoes nothing...

Any hints?

Changing var names is not possible, I can't rename them like tipo[] because they come from multiple radio buttons, so they need differente names or only 1 will be able to be checked in a big list !!!

Link to comment
https://forums.phpfreaks.com/topic/72828-catching-variables/
Share on other sites

I would like to recover the vars in an array

 

What does that meen? There already in an array, the $_POST array. Explain exactly what your trying to achive.

 

Also, its easiest to loop through posted vars with a foreach(). eg;

 

<?php

  foreach($_POST as $k => $v) {
    echo "$k = $v<br />";
  }

?>

Link to comment
https://forums.phpfreaks.com/topic/72828-catching-variables/#findComment-367277
Share on other sites

As I said, I can't rename them like tipo[] because they come from multiple radio buttons, so they need differente names or only 1 will be able to be checked in a big form !!!

I'm sending lot's of vars using whatevername[] from the forms to automatically create the arrays, but with the radio buttons, I can't use the tipo[] name because then is impossible to check more than 1 option.

 

 

Link to comment
https://forums.phpfreaks.com/topic/72828-catching-variables/#findComment-367296
Share on other sites

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.