After changing web server, i get "
PHP Parse error: syntax error, unexpected '[' in ...".
I guess this is because I'm now using another version of PHP. Can't really figure out what the problem is. Can anyone help? The line that gets the error message is "if (count (json_decode ($result, true)['r']) != 0) {
".
function g ($t) {
$output = '';
// Checking that there is a cpe hostname
if (!empty ($t)) {
// Getting the id of the device
$curl = curl_init ();
curl_setopt ($curl, CURLOPT_URL, '...=' . $t);
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt ($curl, CURLOPT_TIMEOUT, 5);
$result = curl_exec($curl);
curl_close ($curl);
if (count (json_decode ($result, true)['r']) != 0) {
// Getting the configuration for the device
$curl = curl_init ();
curl_setopt ($curl, CURLOPT_URL, '...=' . json_decode ($result, true)['r'][0]['id']);
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt ($curl, CURLOPT_TIMEOUT, 5);
$result = curl_exec($curl);
curl_close ($curl);
// If the configuration of the device was found
if (count (json_decode ($result, true)['c']['r']['c']) != 0) {
$output = json_decode ($result, true)['c']['r']['c'];
}
}
}
return $output;
}
I tried looking for other posts here on Stackoverflow with simulare problems without any luck.