1$healthStructureData = [
2 'product' => $product,
3 'website_data' => $website_data,
4 'total_keywords' => $total_keywords,
5 'certificate_status' => $certificate_status,
6 'total_user_websites' => $total_user_websites,
7 ];
8
9foreach ($healthStructureData as $key => $value) {
10 $$key = $value;
11}
1
2<?php
3$array = array(
4 "foo" => "bar",
5 42 => 24,
6 "multi" => array(
7 "dimensional" => array(
8 "array" => "foo"
9 )
10 )
11);
12
13var_dump($array["foo"]);
14var_dump($array[42]);
15var_dump($array["multi"]["dimensional"]["array"]);
16?>
17
18
1
2<?php
3$array = array("foo", "bar", "hello", "world");
4var_dump($array);
5?>
6
7
1class Arr
2{
3 public static function setValue(&$data, $path, $value)
4 {
5 $temp = &$data;
6 foreach ($path as $key) $temp = &$temp[$key];
7 $temp = $value;
8 return $value;
9 }
10
11 public static function getValue(&$data, $path, $value)
12 {
13 $temp = &$data;
14 foreach ($path as $key) $temp = &$temp[$key];
15 return $temp;
16 }
17
18 public static function incValue(&$data, $path, $value)
19 {
20 $temp = (int)self::getValue($data, $path, $value)+$value;
21 self::setValue($data, $path, $temp);
22 }
23}
24
25$d=array();
26Arr::incValue($d,array("the","next","value"),10);
27echo '<pre>'.json_encode($d, JSON_PRETTY_PRINT);
28
29/*
30{
31 "the": {
32 "next": {
33 "value": 10
34 }
35 }
36}
37*/