I have two of these methods. The get_value_from_raw_data method, if found by the key, should return a value, but it always returns false.
public function get_value_from_raw_data($associative_key , $haystack) {
foreach ($haystack as $key => $value) {
if (! is_array($value)) {
if ($key === $associative_key) {
return $value;
} else {
continue;
}
} else if (is_array($value)) {
$this->get_value_from_raw_data($associative_key , $haystack[$key]);
}
}
return false;
}
private function convert_value($value) {
$new_value = $this->get_value_from_raw_data($value['associative_key'] , $this->raw_data);
if ($value['path_to'] !== "") {
$paths = explode('.' , $value['path_to']);
$temp = &$this->used_model;
foreach ($paths as $key) {
$temp = &$temp[$key];
}
$temp[$value['key_name']] = $new_value;
} else {
$this->used_model[$value['key_name']] = $new_value;
}
}
Also, if I use dd inside this method before return, then it displays the value, and after return it is already gone.