Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bicicura's avatar

String changing when saving to DB

Hi!

I have a problem. In a Curl response I recieve a string which I json_decode. Everything fine with the data, yet, when I apply any method / helper related to laravel, some characters change. For example: When I

print_r($result['skills']['sports'][1]['nombre']);

it outputs:

 "FÚTBOL"

When I

dd($result['skills']['sports'][1]['nombre']);

Output:

"FÚTBOL"

The same happens when I try to store the string into the database with the

item->name = $result['skills']['sports'][1]['nombre'];
item->save();

It saves

"FÚTBOL"

Any idea what can be causing this?

0 likes
3 replies
OussamaMater's avatar
Level 37

Maybe do this:

item->name = html_entity_decode($result['skills']['sports'][1]['nombre']);

Edit: if you encounter the same issue in blade files simply change the syntax from {{ }} to {!! !!} (make sure you have a clean serialized data or you'll expose yourself to xss attacks).

Please or to participate in this conversation.