As the title states, I'm trying to use Bootstrap's Typeahead.js, and it requires a JSON string like this
var subjects = ['PHP', 'MySQL', 'SQL', 'PostgreSQL', 'HTML', 'CSS', 'HTML5', 'CSS3', 'JSON'];
But I have a multidimensional array that upon doing json_encode returns the following
[{"username":"Test1"},{"username":"Test2"},{"username":"Test3"},{"username":"Test4"},{"username":"Test5"},{"username":"Test6"}]
Typeahead.js throws out errors when I try using this array.
How would I convert the multidimensional to look like the example one?
Original PHP Array
Array
(
[0] => Array
(
[username] => Test1
)
[1] => Array
(
[username] => Test2
)
[2] => Array
(
[username] => Test3
)
[3] => Array
(
[username] => Test4
)
[4] => Array
(
[username] => Test5
)
[5] => Array
(
[username] => Test6
)
)
Desired outcome would be
var subjects = ['Test1', 'Test2', 'Test3', 'Test4', 'Test5', 'Test6'];
[ "Test1", "Test2", "Test3", "Test4", "Test5", "Test6" ]
? – Mark Reed Oct 11 '13 at 23:58