In meinem php:Wie zeigen Sie PHP-Ausgabewerte in Javascript Var-Attribut?
$result = $conn->query("select address, lat, lang from user where phoneno = '" . $phoneno. "'");
$outp = "[";
while($rs = $result->fetch_array(MYSQLI_ASSOC)) {
if ($outp != "[") {$outp .= ",";}
$outp .= '"' . $rs["address"] . '",';
$outp .= '' . $rs["lat"] . ',';
$outp .= '' . $rs["lang"] . '';
}
$outp .="]";
Der Wert Ausgabe von meinem php: [ "Tampines Straße 86, Singapur", 1.3497658,103.9274115]
var locations = [
['Bondi Beach', -33.890542, 151.274856],
['Coogee Beach', -33.923036, 151.259052],
['Cronulla Beach', -34.028249, 151.157507],
['Manly Beach', -33.80010128657071, 151.28747820854187],
['Maroubra Beach', -33.950198, 151.259302]
];
Die oben ist ein Beispiel dafür, wie ich will mein PHP-Ausgabewert für meine var-Standorte sein. Wie kann ich das machen?
Eine Funktion 'json_encode' –