<?php
if(isset($_GET['loanamount'])) {
$la = $_GET['loanamount'];
} else {
$la = 10000;
}
if(isset($_GET['month'])) {
$m = $_GET['month'];
} else {
$m = 12;
}
$url = "http://some-website.com/api/$la/$m";
// Initiate curl
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$result=curl_exec($ch);
// Closing
curl_close($ch);
//var_dump(json_decode($result, true));
$data = json_decode($result, true);
echo "<pre>";
print_r($data);
echo "</pre>";
// cycle through data call chunk get-table-row-data and insert properties into chunk.
if(!empty($data)) { // checks of the data exists
for($i=0;$i<=count($data);$i++) { // loops through array
$properties = $data[$i]; // array to variable (still an array)
echo $chunk = $modx->getObject('modChunk', array('name'=>'get-table-row-data'));
// this is the bit im stuck with, sending the $properties variable to the chunk and outputting it to the screen
} // end for loop
} // end if statementThis question has been answered by comp_nerd26. See the first response.
$chunk=$modx->parseChunk('get-table-row-data', $params, '[+', '+]');[+array_key+]
