Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 495
jester96 Avatar asked Jun 19 '26 08:06

jester96


1 Answers

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);
like image 180
Matheus Poli Avatar answered Jun 21 '26 21:06

Matheus Poli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!