I have a MySQL query done using PHP, result is presented as array.
$stmt = $mysqli->prepare("SELECT word FROM words ORDER BY RAND() LIMIT 5");
$stmt->bind_result($words);
$stmt->execute();
$result = array();
while ($stmt->fetch()) {
$w = new StdClass();
$w->word = $words;
array_push($result, $w);
}
$stmt->close();
Then, i'm passing the array to javascript using JSON:
'words' : <?php echo json_encode($result); ?>,
But the output is:
[{"word":"Watermelon"},{"word":"Orange"},{"word":"Melon"},{"word":"Cucumber"},{"word":"Apple"}]
Is there any way to "strip" the "word" and make it look like that?
["Watermelon", "Orange", "Melon", "Cucumber", "Apple"]
Thank you in advance.