Adrian Edy Pratama
Adrian Edy Pratama

Reputation: 4031

Laravel Retrieving Translation Strings with Slash Returning the Slash with Backslash

What I try:

// SomeRequest.php
public function attributes()
{
    return [
        'phone' => __('Phone Number'),
    ];
}


// id.json
{
    "Phone Number": "No. Telp / HP"
}

What I expect when I retrieve the id language: No. Telp / HP

What I get: No. Telp \/ HP

Can I retrieve it without additional backslash?

Upvotes: 0

Views: 257

Answers (1)

OMR
OMR

Reputation: 12188

when you return data as a response in Laravel, it automatically encoded to json.

so when your return No. Telp / HP it will be encoded to No. Telp \/ HP

usally, when you get resonose by you request, you decoded to get the result.

$v=json_encode("No. Telp / HP"); // $v will have "No. Telp \/ HP"

$v2 = json_decode($v); // $v2 will have No. Telp / HP

Upvotes: 1

Related Questions