This chunk of code is doing what?

Can you tell me what this section of code (or what the lines of code) is accomplishing?

$pt->show_sub = false;
$pt->sub_categories_array = array(); foreach ($pt->sub_categories as $cat_key => $subs) { 
$pt->sub_categories_array["'".$cat_key."'"] = '<option value="">'.$lang->all.'</option>'; 
foreach ($subs as $sub_key => $sub_value) { 
$pt->sub_categories_array["'".$cat_key."'"] .= '<option value="'.array_keys($sub_value)[0].'" '.((!empty($_GET['sub_id']) && $_GET['sub_id'] == array_keys($sub_value)[0]) ? "selected" : "") .'>'.$sub_value[array_keys($sub_value)[0]].'</option>'; } 
if (!empty($_GET['id']) && $_GET['id'] == $cat_key) { $pt->show_sub = true; }

I look forward to being enlightened

1.) You should format your code properly so everyone can see it easier.
2.) You also didnt provide the 'end of the code?

$pt->show_sub = false;
$pt->sub_categories_array = array(); 
foreach ($pt->sub_categories as $cat_key => $subs) { 
	$pt->sub_categories_array["'".$cat_key."'"] = '<option value="">'.$lang->all.'</option>'; 
	foreach ($subs as $sub_key => $sub_value) { 
		$pt->sub_categories_array["'".$cat_key."'"] .= '<option value="'.array_keys($sub_value)[0].'" '.((!empty($_GET['sub_id']) && $_GET['sub_id'] == array_keys($sub_value)[0]) ? "selected" : "") .'>'.$sub_value[array_keys($sub_value)[0]].'</option>'; 
	} 
	if (!empty($_GET['id']) && $_GET['id'] == $cat_key) { 
		$pt->show_sub = true; 
	}
	
}

While I dont have access to the class/functions you are using… for the most part this is populating a dropdown/select box.

Sponsor our Newsletter | Privacy Policy | Terms of Service