Jump to content

GET ARRAY ERROR


benhaynes

Recommended Posts

Ok, simple problem, I need to get all the GET variables and load them into an array... but the names are dynamic. Here is what Im using now...$ITEMS is an array of what the values COULD be...as loaded from a DB.

[code]for($i=0; $i<count($ITEMS); $i++){

$NAME = $ITEMS[$i];

if($_GET[$NAME]){
        $string .= $ITEMS[$i]."='".$_GET[$NAME]."',";
}

}[/code]



And here is the error I get when I use it...



[code]Warning: Illegal offset type in XXXXXXXXXXXXX/add.php on line 15[/code]


I think i understand the issue, but dont know a work around. Is there a way to just get all GET variables? Hope this makes sense...

Thanks in advance!!!

Ben
Link to comment
https://forums.phpfreaks.com/topic/29010-get-array-error/
Share on other sites

[code]foreach ($_GET AS $key=>$val) {
  $getarray[$key] = stripslashes($val);
}[/code]
will put all the $_GET variables into an array called $getarray.  The array is formatted with the GET variable name as the array key and the value as the array value.

Link to comment
https://forums.phpfreaks.com/topic/29010-get-array-error/#findComment-132906
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.