benhaynes Posted November 30, 2006 Share Posted November 30, 2006 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 More sharing options...
bljepp69 Posted November 30, 2006 Share Posted November 30, 2006 [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 More sharing options...
benhaynes Posted November 30, 2006 Author Share Posted November 30, 2006 SUPERB!!!Thank you SO much, thats exactly what I was looking for. I guess this is the problem with being self taught... you dont know all the easy stuff.Ben Link to comment https://forums.phpfreaks.com/topic/29010-get-array-error/#findComment-132908 Share on other sites More sharing options...
trq Posted November 30, 2006 Share Posted November 30, 2006 What is the point? $_GET [b]is[/b] an array![quote]I guess this is the problem with being self taught... you dont know all the easy stuff.[/quote]99.9% of people developing in php would be self tought. Link to comment https://forums.phpfreaks.com/topic/29010-get-array-error/#findComment-133045 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.