jester96
jester96

Reputation: 33

Saving utf-8 array in database laravel

I have problem with saving utf-8 array in database with laravel. when i save array in database it is stored like this

\u10e4\u10dd\u10dd\u10d3

when i display data it works fine, but when i run search query it displays nothing. database encoding is utf-8 with general_ci collation. i've already tried to encode data before saving in database

json_encode($data, JSON_UNESCAPED_UNICODE);

any ideas?

Upvotes: 3

Views: 1499

Answers (1)

Matheus Poli
Matheus Poli

Reputation: 11

Try storing these arrays in your database using the PHP serialize function instead of encoding for JSON.

serialize($data);

When you want to use the data back, simply deserialize the array with PHP unserialize function.

unserialize($data);

Upvotes: 1

Related Questions