Hey guys sorry for your time but I have came across to an odd situation. I have a database where I store coordinates (php & mysql) with names. When someone searches for something a php script runs and save the query in 3 different variables which it should be of an array type. Then I use JavaScript to convert these php arrays to JavaScript ones. The coordinates are ok, but the names are of type string when I try split() function it gives error because it is an array (as I understand after searching). The other odd is when I console.log the typeof name it says string but when I look in sources it is displayed like an array.
var lon = <?php echo '["' . implode('", "', $lon) . '"]' ?>;
var lat = <?php echo '["' . implode('", "', $lat) . '"]' ?>;
var name = <?php echo '["' . implode('", "', $name) . '"]' ?>;
the output in sources tab (chrome)
var lon = ["39.070200", "39.072365", "39.064469"];
var lat = ["21.018064", "21.017744", "21.000059"];
var name = ["Saint Dimitrios", "Saint Charalampos", "Saint Kosmas"];
and then for the console
console.log(lon);
console.log(typeof lon);
console.log( typeof name);
the actual output in console
["21.018064", "21.017744", "21.000059"] //which when I click it identifies it as an array
object
string
the declaration in php script
$lon = [];
$lat = [];
$name = [];
and the fetching
while ($row = mysqli_fetch_array($query)) {
$name[] = $row['name'];
$lon[] = $row['lon'];
$lat[] = $row['lat'];
}