this is my PHP Code:
<?php
$i = 0;
$output = array();
$kurse = array();
$zusatz = array();
while (isset($_POST['kurs'.$i]))
{
$kurse[$i] = $_POST['kurs'.$i];
$i++;
}
$anzahl = count($kurse);
/* Bestimmt den aktuellen Tag*/
$timestamp = time();
$dw = date( "w", $timestamp);
$day = array('So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So');
$rday= array('Mo', 'Di', 'Mi', 'Do');
$tag1 = $day[$dw];
$tag2 = $day[($dw+1) % 7];
/* read html */
$homepage = "";
if ($dw >= 1 && $dw <= 5) $homepage .= file_get_contents('xyz'.$tag1.'.html');
if (in_array($tag1, $rday) ) $homepage .= file_get_contents('xyz'.$tag2.'.html');
for( $i = 0; $i < $anzahl; $i++){
if ( strpos( $homepage, $kurse[$i] ) !== false )
{
$output[] = $kurse[$i];
}
}
if(empty($output)) {
$response = array();
$response["success"] = 0;
$response["message"] = "Keinen Kurs gefunden";
// echo no users JSON
echo json_encode($response);
}
else {
$response = array();
// success
$response["success"] = 1;
// user node
$response["get"] = $output;
echo json_encode($response);
}
exit();
?>
My JSON output looks like this:
{"success":1,"get":["9b,"6m"]}
But it should look like this:
{"success":1,
"get":[{
"kurs":"9b"
}
},
{
"kurs":"6m"
}
}]
}
What can I do to format this, because I want to use it in my Android Application. I think the solution is quite simple but I don't get it, maybe you can help me...
Thank you in advance :)