I am trying to call a function inside an array as a value but is not working the function instead is echoed outside the array.
Here is my code example:
function plm() {
global $InfoPing;
foreach($InfoPing['description']['extra'] as $plm) {
echo $plm['text'];
}
}
$json = array(
'status' => 'Online',
'motd' => array(
'ingame' => plm()
),
'host' => array(
'host' => $host,
'port' => $port
),
'players' => array(
'max' => $InfoPing['players']['max'],
'online' => $InfoPing['players']['online']
),
'version' => array(
'version' => $version[1],
'protocol' => $InfoPing['version']['protocol']
),
'queryinfo' => array(
'agreement' => 'Ping',
'processed' => $Timer
)
);
echo json_encode($json, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT);
