title: create arrays from elements of another array
body: <p>I have a array called array3;</p>
  
  <pre><code>    Array
  (
      [0] =&gt; Commercial
      [1] =&gt; Infrastructure
  )
  </code></pre>
  
  <p>I want to iterate thtough each element of this array and create individual arrays based on the values. I have tried this;</p>
  
  <pre><code>$array4 = array();
  $array5= array();
  foreach ($array3 as $value) {
    $array4[] = array('v' =&gt; count(search($rows, 'domaindesc', $value)));
    $array4[] = array('v' =&gt; $value);
    $array5[] = array('c' =&gt; $array4);
  
  }
  </code></pre>
  
  <p>the search function is returning the no of maching elements  from another array. The output I get from the above code is </p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [c] =&gt; Array
                  (
                      [0] =&gt; Array
                          (
                              [v] =&gt; 5
                          )
  
                      [1] =&gt; Array
                          (
                              [v] =&gt; Commercial
                          )
  
                  )
  
          )
  
      [1] =&gt; Array
          (
              [c] =&gt; Array
                  (
                      [0] =&gt; Array
                          (
                              [v] =&gt; 5
                          )
  
                      [1] =&gt; Array
                          (
                              [v] =&gt; Commercial
                          )
  
                      [2] =&gt; Array
                          (
                              [v] =&gt; 1
                          )
  
                      [3] =&gt; Array
                          (
                              [v] =&gt; Infrastructure
                          )
  
                  )
  
          )
  
  )
  </code></pre>
  
  <p>What I am trying to get is;</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [c] =&gt; Array
                  (
                      [0] =&gt; Array
                          (
                              [v] =&gt; 5
                          )
  
                      [1] =&gt; Array
                          (
                              [v] =&gt; Commercial
                          )
  
                  )
  
          )
  
      [1] =&gt; Array
          (
              [c] =&gt; Array
                  (                    
  
                      [0] =&gt; Array
                          (
                              [v] =&gt; 1
                          )
  
                      [1] =&gt; Array
                          (
                              [v] =&gt; Infrastructure
                          )
  
                  )
  
          )
  
  )
  </code></pre>
  
  <p>Any help is appreciated </p>