I have a multidimensional array of 10000 rows, and each row is like this:
^ array:n [▼
"static1" => "<HMI screen>"
"static2" => "Testo ON"
"static3" => "s+W+OzXRzgfKrp3VB ▶"
"static4" => ""
"dynamic1" => "foo"
"dynamic2" => "bar"
"dynamic3" => "baz"
"static5" => null
"static6" => null
"static7" => null
"static8" => null
"static9" => null
"static10" => null
...
]
I need to check the first dynamic data, and in some conditions I need to copy the value in dynamic1 key, in all the others dynamic keys
During the iteration of the big array, in some cases I do something like this:
$page[$i] = $row;
$value = $row[$dynamic1];
foreach($dynamicKeys as $key){
$page[$i][$key] = $value;
}
So I overwrite the all the dynamic key values with the firs dynamic key value.
In the $dynamicsKey I have all the keys value of the dynamics keys except the first one, example:
$dynamicKeys = ['dynamic2','dynamic3'..];
Exist a native PHP function to do this:
$value = $page[$i]['dynamic1']; (in most case non everytime)
$page[$i] = magicNativePHPFunction($value,$dynamicKeys);
and the result should be:
^ array:n [▼
"static1" => "<HMI screen>"
"static2" => "Testo ON"
"static3" => "s+W+OzXRzgfKrp3VB ▶"
"static4" => ""
"dynamic1" => "foo"
"dynamic2" => "foo"
"dynamic3" => "foo"
"static5" => null
"static6" => null
"static7" => null
"static8" => null
"static9" => null
"static10" => null
...
]