简体   繁体   中英

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?

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM