Answer the question
In order to leave comments, you need to log in
How to disable quote escaping when passing PHP array to JavaScript?
Outputs a string with quotes. In a PHP array, these are regular strings.
var sgGames = {{ json_encode($suggestedGames) }};
// result
var sgGames = ["Counter-Strike","Half-Life",
// needed
var test= ['Counter-Strike', 'Half-Life' ,'Counter-Strike',...];
$suggestedGames = SteamGame::pluck('name')->toArray();
return view('add_game', compact('suggestedGames'));
Answer the question
In order to leave comments, you need to log in
Blade automatically escapes everything it outputs. You can disable shielding like this:{!! json_encode($suggestedGames) !!};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question