I have a function that returns an array of default value types like so:
//////////////////////////////////////
// FUNCTION - CUSTOM FIELD TYPES
function customFieldTypes(){
$types[1] = 'Textbox';
$types[2] = 'Dropdown';
$types[3] = 'Checkbox';
$types[4] = 'Radio Button';
// RETURN
return $types;
} // END FUNCTION
I know you can loop through each without having to create an array to hold the values like:
foreach(customFieldTypes() as $type){
// DISPLAY
echo $type.' ';
}
would show Textbox Dropdown Checkbox Radio Button
my question is. Is there a way to go into that array without going
$arrayResult = customFieldTypes();
echo $arrayResult[2];
My only idea of doing this would be like:
echo customFieldTypes()[2];
but it give me a error saying unexpected '[', expecting ',' or ';'
is there anyway to do this? I do realize it's a shortcut but I was just wondering