Hi,
I’ve looked around these forums, and around the internet for about 3 hours now.
Basically, I’m trying to create a function which looks for a string in the appropriate array and then returns “show” or “hide” - with a minimum of coding.
So far this is what I have :
[php]$AccountsArray = array(‘ViewCompanies’,‘Currencies’,‘ViewCurrencies’,‘EditCurrency’,‘Departments’,‘ViewDepartments’,‘EditDepartment’,‘ProductCodes’,‘ViewProducts’,‘EditProduct’,‘VATCodes’,‘ViewVATCodes’,‘EditVATCode’);
$AdminArray = array(‘Admin’,‘Currencies’,‘ViewCurrencies’,‘EditCurrency’,‘Departments’,‘ViewDepartments’,‘EditDepartment’,‘ProductCodes’,‘ViewProducts’,‘EditProduct’,‘VATCodes’,‘ViewVATCodes’,‘EditVATCode’);
$CurrenciesArray = array(‘ViewCurrencies’,‘EditCurrency’);
$DepartmentsArray = array(‘ViewDepartments’,‘EditDepartment’);
$ProductCodesArray = array(‘ViewProducts’,‘EditProduct’);
$VATCodesArray = array(‘ViewVATCodes’,‘EditVATCode’);
$CompaniesArray = array(‘EditCompany’,‘ViewCompanies’);
$PurchaseOrdersArray = array(‘EditPO’,‘Attachments’,‘ViewAttachments’,‘EditAttachment’,‘Events’,‘ViewEvents’,‘EditEvent’,‘Notes’,‘ViewNotes’,‘EditNote’);
$AttachmentsArray = array(‘ViewAttachments’,‘EditAttachments’);
$EventsArray = array(‘ViewEvent’,‘EditEvent’);
$NotesArray = array(‘ViewNotes’,‘EditNote’);
function checkExpand($Group, $PageName)
{
$ArrayName=${$Group.'Array'};
if(in_array($PageName,$ArrayName)) {
$Return="show";
} else {
$Return="hide";
}
return $Return;
}
echo checkExpand(“Admin”,“Departments”); //This bit is just for the purpose of this post
[/php]
I just get nothing - I’ve tried all different variations of turning a string into a variable name, but nothing is working.
Any ideas? I am using PHP V5.1.6
Thanks,
George