I am using the following code to get data from $_REQUEST in php:
for($i=0;$i<intval($q);$i++)
{
$construct="'".$i."'";
echo $construct;
$p=$_REQUEST[$construct];
echo $p;
}
where ‘0’,’1′,… so on have values. But for some reason it does not work. However if I replace it by $_REQUEST[‘0’] it seems to print the value fine. Any ideas what I am doing wrong?
Your
$constructvariable’s value contains single quotes, which are not necessary. When you write it out as'0'you are indicating an actual value of0, whereas"'0'"indicates a value of'0'. Your code should read:or more simply: