title: splitting a multidimensional array in php
body: <p>i have a PHP array as follow : </p>
  
  <pre><code>$array = array("one" =&gt; "is one" , "two" =&gt; "is two" , "three" =&gt; "is three", "four" =&gt; "is four" , "five" =&gt; "is five" , "six" =&gt; "is six" , "seven" =&gt; "is seven" , "eight" =&gt; "is eight" , "nine" =&gt; "is nine" , "ten" =&gt; "is ten");
  </code></pre>
  
  <p>After partitioning this array into two groups that is 5 elements, using following method: </p>
  
  <pre><code> function partition(Array $list, $p) {
      $listlen = count($list);
      $partlen = floor($listlen / $p);
      $partrem = $listlen % $p;
      $partition = array();
      $mark = 0;
      for($px = 0; $px &lt; $p; $px ++) {
          $incr = ($px &lt; $partrem) ? $partlen + 1 : $partlen;
          $partition[$px] = array_slice($list, $mark, $incr);
          $mark += $incr;
      }
      return $partition;
  }
  $partitioned = partition($array , 2);
  </code></pre>
  
  <p>Now to use this partitioned array i use the following code : </p>
  
  <pre><code>$totalArrays = count($partitioned);
  for($pb=0; $pb &lt; $totalArrays; $pb++){
      print_r($partitioned[$pb]);
  
  }
  </code></pre>
  
  <p>The above <code>print_r($partitioned[$pb]);</code> outputs 2 arrays.</p>
  
  <p>This displays the contents of both arrays as keys and values, what i actually wanted to achieve is that , i would like to save elements of first array into one file named "First.txt" and "Second.txt" for the second, the names doesn't matters they can be numbered but what matters is the partitions, forexample if there are 10 partitions each partition will save its element into its own file.</p>
  
  <p>I have had some solutions but they ain't working as expected so i am here to request for your solutions.</p>
  
  <p>Thank you.</p>