Create dynamic array name - assign values to it
Posted: Sat Aug 09, 2014 4:31 pm
Hi,
I need help to construct an array totally dynamically including the name.
I have a 'project' array $projects and a 'materials' array $materials.
$projects structure - projid, project
$materials structure - project, workcode, description, cost, tax, invno, vendor.
What I want to do is create an array for each project comprised of elements taken from the materials array. This includes creating the name,
ie: Where $project['project'] = 'house'
create an array called $house and pick all indexes and values from the $materials array having $materials['project'] named 'house'.
QUESTION How can I create the array "$house" from $myVar="$".$project['project']."[]" ($myVar would then be '$house[]')
And then assign values to it:
$myVar=$materials[$i]['description']." - ".$materials[$i]['cost']." - ".$materials[$i]['tax'] ... etc.
I've tried {$myVar}, ($myVar), "$myVar", '$myVar' etc., etc.
Thanks in advance R.
I need help to construct an array totally dynamically including the name.
I have a 'project' array $projects and a 'materials' array $materials.
$projects structure - projid, project
$materials structure - project, workcode, description, cost, tax, invno, vendor.
What I want to do is create an array for each project comprised of elements taken from the materials array. This includes creating the name,
ie: Where $project['project'] = 'house'
create an array called $house and pick all indexes and values from the $materials array having $materials['project'] named 'house'.
QUESTION How can I create the array "$house" from $myVar="$".$project['project']."[]" ($myVar would then be '$house[]')
And then assign values to it:
$myVar=$materials[$i]['description']." - ".$materials[$i]['cost']." - ".$materials[$i]['tax'] ... etc.
I've tried {$myVar}, ($myVar), "$myVar", '$myVar' etc., etc.
Thanks in advance R.