Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to bind the two array results and Print it in a right output PHP
    primarykey
    data
    text
    <p>I have two data here:</p> <p>The result of this first function:</p> <pre><code>Array ( [2] =&gt; Array ( [SiteID] =&gt; 2 [Balance] =&gt; 19000.00 [MinBalance] =&gt; 100000.00 [MaxBalance] =&gt; 1000000.00 [OwnerAID] =&gt; 83 [GroupID] =&gt; 1 ) [3] =&gt; Array ( [SiteID] =&gt; 3 [Balance] =&gt; 94000.99 [MinBalance] =&gt; 100000.00 [MaxBalance] =&gt; 500000.00 [OwnerAID] =&gt; 17 [GroupID] =&gt; 1 ) [4] =&gt; Array ( [SiteID] =&gt; 4 [Balance] =&gt; 1000000.00 [MinBalance] =&gt; 100000.00 [MaxBalance] =&gt; 1000000.00 [OwnerAID] =&gt; 12 [GroupID] =&gt; 1 ) </code></pre> <p>)</p> <p>The result of the second function:</p> <pre><code> Array ( [3] =&gt; Array ( [Deposit] =&gt; 459000 [Reload] =&gt; 169100 [Redemption] =&gt; 703576 ) [2] =&gt; Array ( [Deposit] =&gt; 1500 [Reload] =&gt; 1000 [Redemption] =&gt; 1000 ) ) </code></pre> <p>Now, I need to bind the result of thie two functions, I try it with this codes:</p> <pre><code> public function bindGHComponentsToSites() { error_reporting (E_ALL^ E_NOTICE); $combine = array(); foreach ($this-&gt;arrays as $keys =&gt; $data) { foreach($this-&gt;result as $keyss =&gt; $value){ if($data['SiteID'] == $keyss){ $merged = array_merge((array)$data, (array)$value); } else if ($data['SiteID'] != $keyss){ $val = array('Deposit'=&gt;0, 'Reload'=&gt;0, 'Redemption'=&gt;0); $merged = array_merge((array)$data, (array)$val); } } $this-&gt;combined[$data['SiteID']] = $merged; } print_r($this-&gt;combined); } </code></pre> <p>But, I got the wrong output, the condition was, If the SiteID of bindownertosites doesn't match to the SiteId of Computeghcomponents then just print the value of the Deposit, Reload and Redemption should be equal to zero. </p> <p>The Deposit, Reload and Redemption are all equal to zero which is wrong.Here's should be the right result:</p> <pre><code>Array ( [2] =&gt; Array ( [SiteID] =&gt; 2 [Balance] =&gt; 19000.00 [MinBalance] =&gt; 100000.00 [MaxBalance] =&gt; 1000000.00 [OwnerAID] =&gt; 83 [GroupID] =&gt; 1 [Deposit] =&gt; 1500 [Reload] =&gt; 1000 [Redemption] =&gt; 1000 ) [3] =&gt; Array ( [SiteID] =&gt; 3 [Balance] =&gt; 94000.99 [MinBalance] =&gt; 100000.00 [MaxBalance] =&gt; 500000.00 [OwnerAID] =&gt; 17 [GroupID] =&gt; 1 [Deposit] =&gt; 459000 [Reload] =&gt; 169100 [Redemption] =&gt; 703576 ) [4] =&gt; Array ( [SiteID] =&gt; 3 [Balance] =&gt; 94000.99 [MinBalance] =&gt; 100000.00 [MaxBalance] =&gt; 500000.00 [OwnerAID] =&gt; 17 [GroupID] =&gt; 1 [Deposit] =&gt; 0 [Reload] =&gt; 0 [Redemption] =&gt; 0 ) ) </code></pre> <p>Is it possible to have this kind of result? Please help me guys, I've been working with this almost one week, but I always got a wrong output. I appreciate to your response.I put everything here to make clarify those things.Kindly review my question before you answer. Please help me and guide me in proper way. Thank you in advance. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload