I am trying to append values I selected from database into an array inside foreach loop, but I don't seem to achieve much, because I only get the first value into the array and not the rest.
Here is what I have tried so far:
<?php
include 'include/states_info.php';
header('Content-Type: application/json');
$infoObject = json_decode(stripcslashes(file_get_contents('php://input')));
if ( $infoObject->operation == 'get_all_states_info' )
{
$statesInfo = new StatesInfo();
$sInfoArr = $statesInfo->getAll();
$resultObject = array();
if ( $sInfoArr != null )
{
foreach ( $sInfoArr as $sInfo )
{
$resultObject += array(
'coords' => array(
'lat' => $sInfo['lat'],
'lng' => $sInfo['lng']
),
'name' => $sInfo['name'],
'heat' => 0
);
}
}
echo json_encode($resultObject);
}