Forum Moderators: coopster
$name = $_GET['name']; // user inputs "WebmasterWorld", for example
$arr = [
'csdude' = [
'lorem' => 14,
'ipsum' => 427,
'this' => 49,
'that' => 62,
'whatever' => 27
],
'WebmasterWorld' = [
'lorem' => 211,
'ipsum' => 38,
'this' => 119,
'that' => 30,
'whatever' => 318
]
];
if (isset($foo)) {
$arr['csdude']['this'] = 50;
$arr['csdude']['whatever'] = 729;
$arr['WebmasterWorld']['this'] = 207;
$arr['WebmasterWorld']['whatever'] = 6;
} $name = 'WebmasterWorld';
$arr = [
'csdude' = [
'lorem' => 14,
'ipsum' => 427,
'this' => 49,
'that' => 62,
'whatever' => 27
],
'WebmasterWorld' = [
'lorem' => 211,
'ipsum' => 38,
'this' => 119,
'that' => 30,
'whatever' => 318
]
];
$alt= [
'csdude' = [
'this' => 50,
'whatever' => 729
],
'WebmasterWorld' = [
'this' => 207,
'whatever' => 6
]
];
if (isset($foo))
foreach (['this', 'whatever'] as $key)
$arr[$name][$key] = $alt[$name][$key];
$name = 'WebmasterWorld';
foreach ($arr[$name] as $k => $v)
$$k = 'this, ' . $v . ', that';
echo <<<EOF
$lorem
$ipsum
$this
$that
$whatever
EOF;