Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to add two different array in to simple for each loop
    text
    copied!<p>Hello Friend my Question is Quite simple but difficult to understand I think so.</p> <p>Here is some more code :-</p> <pre><code> $graph1 = new gapi($ga_email,$ga_password); $dimensions = array('date'); $metrics = array('visits'); $graph1-&gt;requestReportData($ga_profile_id, $dimensions, $metrics, 'date' ); $graph2 = new gapi($ga_email,$ga_password); $dimensions = array('date'); $metrics = array('visits'); $graph2-&gt;requestReportData($ga_profile_id, $dimensions, $metrics, 'date', $filter, // Filter the data '2012-09-07', // Start Date '2012-10-07', // End Date 1, // Start Index 500 // Max results ); </code></pre> <p>I have an array lets say </p> <pre><code> $resultsg1 = $graph1-&gt;getResults(); </code></pre> <p>and </p> <pre><code> $resultsg2 = $graph2-&gt;getResults(); </code></pre> <p>and I am trying to fetch this value from for each loop code is here</p> <pre><code>data.addRows([ &lt;?php foreach($results as $result) { echo '["'.date("l, F j, Y",strtotime($result-&gt;getDate())).'", '.$result-&gt;getVisits().'," Visits :'.$result-&gt;getVisits().'","'.date("l, F j, Y",strtotime($result-&gt;getDate())).'",'.$result-&gt;getVisits().'," Visits :'.$result-&gt;getVisits().'"],'; } ?&gt; ]); </code></pre> <p>Now My Question I need an output something like this :-</p> <pre><code>foreach($resultsg1 as $result1 and resultsg2 as $results2 ) { echo '["'.date("l, F j, Y",strtotime($result1-&gt;getDate())).'", '.$result1-&gt;getVisits().'," Visits :'.$result1-&gt;getVisits().'","'.date("l, F j, Y",strtotime($result2-&gt;getDate())).'",'.$result2-&gt;getVisits().'," Visits :'.$result2-&gt;getVisits().'"],'; } ?&gt; ]); </code></pre> <p>Any help is highly appreciated.... :)</p> <p><strong>Note</strong>:- Purpose of this code is to simply create a graph with two different months.</p>
 

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