重置多维数组的值从字符串递归到布尔值

I need to reset values from a multidimensional array. The array gets stored into the database. This means that booleans and numbers get stored as strings (serialize function PHP).

When I load the array from the database, these values need a reset to change back to being booleans and numbers.

I tried writing a recursive function for it, but somethings seems off:

 public function reset_values_recursive($haystack) {
    foreach($haystack as $key=>$value) {
        if(is_array($value)){
            $haystack[$key] = $this->reset_values_recursive($value);
        } else if($value === 'true') {
            $haystack[$key] = 1;
            return $haystack[$key];
        } else if($value === 'false') {
            $haystack[$key] = 0;
            return $haystack[$key];
        }
    }
    return false;
}

A part of the array:

beforeArray
(
[image] => Array
    (
        [image_upload] => http://placehold.it/150x100&text=afbeelding
    )

[foreground] => Array
    (
        [color] => 0
        [text_location] => false
        [column_title_toggle] => false
        [title] => Array
            (
                [column_title_centre_toggle] => true
                [column_title_pattern] => true
            )

    )

[background] => Array
    (
        [background_color] => 0
        [background_pattern] => none
        [background_pattern_transparency] => 0
        [background_overlay_toggle] => false
        [overlay] => Array
            (
                [background_overlay_color] => default_color
                [background_overlay_transparency] => 0
            )

        [background_image_toggle] => false
        [image] => Array
            (
                [background_parallax_toggle] => false
                [image_upload] => http://placehold.it/150x100&text=afbeelding
            )

    )
)

I'm sorry if this is a simple question, I am having diffulties understanding recursive functions atm.