This is a bit of an odd one. I am building an array in PHP and then encoding it to JSON before I spit it out.
$arr = array (
'reportDescription' =>
array (
if ($queryType == "realtime")
{
'source' => 'realtime',
}
'reportSuiteID' => 'rbsglobretailprod',
'dateGranularity' => $queryGran,
'dateFrom' => $queryFrom,
'dateTo' => $queryTo,
'elements' =>
array (
0 =>
array (
'id' => $queryElement,
),
),
'metrics' =>
array (
0 =>
array (
'id' => $queryMetric,
),
),
),
);
I am trying to get it to add a line to the array if the query type is realtime. This is what I tried but I'm not sure if it's possible to do this, and if it's not, I'm not sure how I should approach it. The error I get below suggests it may not be possible:
Parse error: syntax error, unexpected 'if' (T_IF), expecting ')'