I'm trying to add a newline \n
, in my foreach statement with implode.
My code:
$ga->requestReportData($profileId,array('country'),array('visits'));
$array = array();
foreach($ga->getResults() as $result){
$array[] = "['".$result->getcountry()."', ".$result->getVisits()."]";
}
echo implode(",\n", $array);
I only get a comma and a space between my results. I want a comma and a newline.
I am trying to get something like this:
['Country', 'number'],
['Country', 'number'],
['Country', 'number']
However I I get this:
['Country', 'number'], ['Country', 'number'], ['Country', 'number']
Why does my \n not cause a newline?
<pre></pre>
tag or you will only see a space – Forwardsimplode( ",\n",$array);
see: bd1.php.net/function.implode – Aiden