title: PHP - Problems with function return and multidimensional array
body: <p>I have the next issue, I have this multidimensional array:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-14 07:00
                      [end_date] =&gt; 2016-07-14 07:20
                      [type] =&gt; 2
                  )
  
              [1] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-14 07:20
                      [end_date] =&gt; 2016-07-14 07:40
                      [type] =&gt; 2
                  )
  
              [2] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-14 07:40
                      [end_date] =&gt; 2016-07-14 08:00
                      [type] =&gt; 2
                  )
  
              [3] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-14 08:00
                      [end_date] =&gt; 2016-07-14 08:15
                      [type] =&gt; 3
                  )
  
              [4] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-14 08:15
                      [end_date] =&gt; 2016-07-14 08:30
                      [type] =&gt; 3
                  )
  
          )
  
      [1] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-15 07:00
                      [end_date] =&gt; 2016-07-15 07:20
                      [type] =&gt; 2
                  )
  
              [1] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-15 07:20
                      [end_date] =&gt; 2016-07-15 07:40
                      [type] =&gt; 2
                  )
  
              [2] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-15 07:40
                      [end_date] =&gt; 2016-07-15 08:00
                      [type] =&gt; 2
                  )
  
              [3] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-15 08:00
                      [end_date] =&gt; 2016-07-15 08:15
                      [type] =&gt; 3
                  )
  
              [4] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-15 08:15
                      [end_date] =&gt; 2016-07-15 08:30
                      [type] =&gt; 3
                  )
  
          )
  
      [2] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-18 07:00
                      [end_date] =&gt; 2016-07-18 07:20
                      [type] =&gt; 2
                  )
  
              [1] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-18 07:20
                      [end_date] =&gt; 2016-07-18 07:40
                      [type] =&gt; 2
                  )
  
              [2] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-18 07:40
                      [end_date] =&gt; 2016-07-18 08:00
                      [type] =&gt; 2
                  )
  
              [3] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-18 08:00
                      [end_date] =&gt; 2016-07-18 08:15
                      [type] =&gt; 3
                  )
  
              [4] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-18 08:15
                      [end_date] =&gt; 2016-07-18 08:30
                      [type] =&gt; 3
                  )
  
          )
  
      [3] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-19 07:00
                      [end_date] =&gt; 2016-07-19 07:20
                      [type] =&gt; 2
                  )
  
              [1] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-19 07:20
                      [end_date] =&gt; 2016-07-19 07:40
                      [type] =&gt; 2
                  )
  
              [2] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-19 07:40
                      [end_date] =&gt; 2016-07-19 08:00
                      [type] =&gt; 2
                  )
  
              [3] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-19 08:00
                      [end_date] =&gt; 2016-07-19 08:15
                      [type] =&gt; 3
                  )
  
              [4] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-19 08:15
                      [end_date] =&gt; 2016-07-19 08:30
                      [type] =&gt; 3
                  )
  
          )
  
      [4] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-20 07:00
                      [end_date] =&gt; 2016-07-20 07:20
                      [type] =&gt; 2
                  )
  
              [1] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-20 07:20
                      [end_date] =&gt; 2016-07-20 07:40
                      [type] =&gt; 2
                  )
  
              [2] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-20 07:40
                      [end_date] =&gt; 2016-07-20 08:00
                      [type] =&gt; 2
                  )
  
              [3] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-20 08:00
                      [end_date] =&gt; 2016-07-20 08:15
                      [type] =&gt; 3
                  )
  
              [4] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-20 08:15
                      [end_date] =&gt; 2016-07-20 08:30
                      [type] =&gt; 3
                  )
  
          )
  
      [5] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-21 07:00
                      [end_date] =&gt; 2016-07-21 07:20
                      [type] =&gt; 2
                  )
  
              [1] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-21 07:20
                      [end_date] =&gt; 2016-07-21 07:40
                      [type] =&gt; 2
                  )
  
              [2] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-21 07:40
                      [end_date] =&gt; 2016-07-21 08:00
                      [type] =&gt; 2
                  )
  
              [3] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-21 08:00
                      [end_date] =&gt; 2016-07-21 08:15
                      [type] =&gt; 3
                  )
  
              [4] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-21 08:15
                      [end_date] =&gt; 2016-07-21 08:30
                      [type] =&gt; 3
                  )
  
          )
  
      [6] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-22 07:00
                      [end_date] =&gt; 2016-07-22 07:20
                      [type] =&gt; 2
                  )
  
              [1] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-22 07:20
                      [end_date] =&gt; 2016-07-22 07:40
                      [type] =&gt; 2
                  )
  
              [2] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-22 07:40
                      [end_date] =&gt; 2016-07-22 08:00
                      [type] =&gt; 2
                  )
  
              [3] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-22 08:00
                      [end_date] =&gt; 2016-07-22 08:15
                      [type] =&gt; 3
                  )
  
              [4] =&gt; Array
                  (
                      [start_date] =&gt; 2016-07-22 08:15
                      [end_date] =&gt; 2016-07-22 08:30
                      [type] =&gt; 3
                  )
  
          )
  
  )
  </code></pre>
  
  <p>In addition, I have the following function:</p>
  
  <pre><code>public function transformValue($array = [], $level = 1) {
      $return = [];
      foreach($array as $key =&gt; $value){
          if(is_array($value)){
              $this-&gt;transformValue($value, $level + 1);
          } else{
              $return[$key] = $value;
          }
      }
      return $return;
  
  }
  </code></pre>
  
  <p>This function receives this multi-array as a parameter, as I need to normalize it as follows:</p>
  
  <pre><code>Array
  (
      [start_date] =&gt; 2016-07-14 07:00
      [end_date] =&gt; 2016-07-14 07:20
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-14 07:20
      [end_date] =&gt; 2016-07-14 07:40
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-14 07:40
      [end_date] =&gt; 2016-07-14 08:00
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-14 08:00
      [end_date] =&gt; 2016-07-14 08:15
      [type] =&gt; 3
  )
  Array
  (
      [start_date] =&gt; 2016-07-14 08:15
      [end_date] =&gt; 2016-07-14 08:30
      [type] =&gt; 3
  )
  Array
  (
      [start_date] =&gt; 2016-07-15 07:00
      [end_date] =&gt; 2016-07-15 07:20
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-15 07:20
      [end_date] =&gt; 2016-07-15 07:40
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-15 07:40
      [end_date] =&gt; 2016-07-15 08:00
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-15 08:00
      [end_date] =&gt; 2016-07-15 08:15
      [type] =&gt; 3
  )
  Array
  (
      [start_date] =&gt; 2016-07-15 08:15
      [end_date] =&gt; 2016-07-15 08:30
      [type] =&gt; 3
  )
  Array
  (
      [start_date] =&gt; 2016-07-18 07:00
      [end_date] =&gt; 2016-07-18 07:20
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-18 07:20
      [end_date] =&gt; 2016-07-18 07:40
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-18 07:40
      [end_date] =&gt; 2016-07-18 08:00
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-18 08:00
      [end_date] =&gt; 2016-07-18 08:15
      [type] =&gt; 3
  )
  Array
  (
      [start_date] =&gt; 2016-07-18 08:15
      [end_date] =&gt; 2016-07-18 08:30
      [type] =&gt; 3
  )
  Array
  (
      [start_date] =&gt; 2016-07-19 07:00
      [end_date] =&gt; 2016-07-19 07:20
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-19 07:20
      [end_date] =&gt; 2016-07-19 07:40
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-19 07:40
      [end_date] =&gt; 2016-07-19 08:00
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-19 08:00
      [end_date] =&gt; 2016-07-19 08:15
      [type] =&gt; 3
  )
  Array
  (
      [start_date] =&gt; 2016-07-19 08:15
      [end_date] =&gt; 2016-07-19 08:30
      [type] =&gt; 3
  )
  Array
  (
      [start_date] =&gt; 2016-07-20 07:00
      [end_date] =&gt; 2016-07-20 07:20
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-20 07:20
      [end_date] =&gt; 2016-07-20 07:40
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-20 07:40
      [end_date] =&gt; 2016-07-20 08:00
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-20 08:00
      [end_date] =&gt; 2016-07-20 08:15
      [type] =&gt; 3
  )
  Array
  (
      [start_date] =&gt; 2016-07-20 08:15
      [end_date] =&gt; 2016-07-20 08:30
      [type] =&gt; 3
  )
  Array
  (
      [start_date] =&gt; 2016-07-21 07:00
      [end_date] =&gt; 2016-07-21 07:20
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-21 07:20
      [end_date] =&gt; 2016-07-21 07:40
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-21 07:40
      [end_date] =&gt; 2016-07-21 08:00
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-21 08:00
      [end_date] =&gt; 2016-07-21 08:15
      [type] =&gt; 3
  )
  Array
  (
      [start_date] =&gt; 2016-07-21 08:15
      [end_date] =&gt; 2016-07-21 08:30
      [type] =&gt; 3
  )
  Array
  (
      [start_date] =&gt; 2016-07-22 07:00
      [end_date] =&gt; 2016-07-22 07:20
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-22 07:20
      [end_date] =&gt; 2016-07-22 07:40
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-22 07:40
      [end_date] =&gt; 2016-07-22 08:00
      [type] =&gt; 2
  )
  Array
  (
      [start_date] =&gt; 2016-07-22 08:00
      [end_date] =&gt; 2016-07-22 08:15
      [type] =&gt; 3
  )
  Array
  (
      [start_date] =&gt; 2016-07-22 08:15
      [end_date] =&gt; 2016-07-22 08:30
      [type] =&gt; 3
  )
  </code></pre>
  
  <p><strong>MY PROBLEM</strong>: When I call my function and assigned to a variable, it appears that the function does not assign any value to the variable, but if I check the return of the function with a print_r() shows the values as we need. I should be skipping is things and I need a "push" to continue. It is in this way that declare the variable with the return of function:</p>
  
  <pre><code>$return_value_function = [];
  $return_value_function = $this-&gt;transformValue($array_values);
  </code></pre>
  
  <p>The variable $return_value_function does not save the function return. Where is my mistake?</p>