I need to get the Type value (1 & 8) from the $_GET. Please see the content of $_GET when using print_r($_GET);
Array ( [pageid] => 0 [project] => 1 [groups] => Array ( [0] => Array ( [GroupName] => RGB [Type] => 1 [IDs] => 38;39;3;4;5;6;7;8;9;10;106 ) [1] => Array ( [GroupName] => GeoJSON [Type] => 8 [IDs] => 44;49 ) )
Currently I am trying
$type = $_GET["groups"]["Type"]; _log("type: " .$type);
This does not return any values. Later on, these Type’s values will be used for SQL queries. Ex.:
if ($type != "%" && $type != "8") { } elseif ($type == "8"){ }
Answer
You have many groups within your GET, so assume they’re added dynamically. The best way for getting each one is… iterating the sub-array
foreach ($_GET['groups'] as $group){ var_dump($group['Type']); }
if you want just to get the type of the first group without itteration, just use
var_dump($_GET['groups'][0]['Type']);
for second
var_dump($_GET['groups'][1]['Type']);
etc.