I'm a beginer in PHP programming, i want to ask for my problem here.
Before, i get the PHP scripts from: https://github.com/VosCast/SHOUTcast-PHP-Stats
This is the code, how i get the array:
require_once 'vc_shoutcast.class.php'; // get stats
require_once 'vc_shoutcast_json_relay.class.php'; // produce json
$lists = array(
array(
'host' => 'host.net',
'port' => '9898'
),
array(
'host' => 'host.net',
'port' => '8787'
)
);
$i = 1;
foreach ($lists as $list => $radio) {
$vc_shoutcast = new vc_shoutcast( $radio['host'], $radio['port'], false );
$vc_shoutcast_json_relay = new vc_shoutcast_json_relay( $vc_shoutcast, 1, $cache = './stats_' . $i . '.json' );
$vc_shoutcast_json_relay->run( 'both' );
$i++;
}
This is the vc_shoutcast_json_relay.class.php ( $vc_shoutcast_json_relay->run( 'both' ); ) code:
foreach ($vars as $value) {
$data[$value] = $this->vc_shoutcast->$value;
}
var_dump( $data );
From the code above, I'll get two outputs array, like this:
Array(
[currentlisteners] => 2,
[maxlisteners] => 3,
[songtitle] => Some song title 2
)
Array(
[currentlisteners] => 12,
[maxlisteners] => 13,
[songtitle] => Some song title 2
)
How do I merge two arrays into one array become:
Array(
[0] => (
[currentlisteners] => 2,
[maxlisteners] => 3,
[songtitle] => Some song title 2
),
[1] => (
[currentlisteners] => 12,
[maxlisteners] => 13,
[songtitle] => Some song title 2
)
)
I know, i can merge 2 arrays with array_merge( $data ) or with something similiar functions, but it isn't works.
Thanks for your help.
$data.array($data1, $data2).