xxxxxxxxxx
$healthStructureData = [
'product' => $product,
'website_data' => $website_data,
'total_keywords' => $total_keywords,
'certificate_status' => $certificate_status,
'total_user_websites' => $total_user_websites,
];
foreach ($healthStructureData as $key => $value) {
$$key = $value;
}
xxxxxxxxxx
class Arr
{
public static function setValue(&$data, $path, $value)
{
$temp = &$data;
foreach ($path as $key) $temp = &$temp[$key];
$temp = $value;
return $value;
}
public static function getValue(&$data, $path, $value)
{
$temp = &$data;
foreach ($path as $key) $temp = &$temp[$key];
return $temp;
}
public static function incValue(&$data, $path, $value)
{
$temp = (int)self::getValue($data, $path, $value)+$value;
self::setValue($data, $path, $temp);
}
}
$d=array();
Arr::incValue($d,array("the","next","value"),10);
echo '<pre>'.json_encode($d, JSON_PRETTY_PRINT);
/*
{
"the": {
"next": {
"value": 10
}
}
}
*/