如何为其他两个变量的数据分配一个新变量?

I have two variables:

$getSkill = $_GET['skill'];
$avg = avg;

I have an 'averages.php' file included that has all of the necessary averages preloaded but this current PHP file is defined by $_GET['skill'], each average in there is loaded as $skillnameAvg and I am trying to echo the relevant $skillnameAvg to each dynamic page correctly.

I've tried $getSkillAvg = $.$getSkill.$avg; and a few others and I can't seem to find a solution.

This can be done using Variables variables in PHP

$getSkill = $_GET['skill'];
$avg = $getSkill . 'avg';
echo $$avg;

Example

$chippyavg = '20%';  // create a testing value eg your included file

$getSkill = 'chippy'
$avg = $getSkill . 'avg';

echo $$avg;

Result

20%

This is not a big deal, but for you I can share some information. First of all you need to concatenate two variable $_GET['skill'] and $avg, and make them also another variable by using a $sign prefix of the resultant value.

Now use echo $getSkillAvg = ${$getSkill.$avg};, what it shows? If you don't define the variable that is generated here then E_NOTICE : type 8 -- Undefined variable: skillavg -- at line 8. Or if defined then the value will be display.

Now what you are trying to do make that value a variable, so do that you need to use another $ sign before the resultant value. Then the result says undefined variable, so you need to make that variable as string to show as output as i do in below code.

$skillavg = 'Smith';     //assignment for work
$_GET['skill'] = 'skill';//assignment for work

$getSkill = $_GET['skill'];
$avg = "avg";

echo $getSkillAvg = "$${$getSkill.$avg}"; //$Smith