I have the following php code that I am looking to put into an array, and then json_encode:
$teamQuery = $xpath->query("//td[@align='left']");
$pointsQuery = $xpath->query("//td[@class='sortcell']");
$data = array ();
for($x=1; $x<=30; $x++){
$data[$x]['id'] = $teamQuery->item($x)->nodeValue;
$data[$x]['Team Points'] = $pointsQuery->item($x)->nodeValue;
}
echo json_encode($data);
The output looks like this:
{"1":{"id":"Team Query\n","Points Query":"110"},"
For the purposes of my project I would like to remove the line break (\n), as well as the leading {"1": in the code.
Any help and guidance would be greatly appreciated!
$data[$x])