I want to remove some special characters from a result of this query, this is the query:
$permiso = DB::table('personal_access_tokens')->select('abilities')->where('tokenable_id',$id)->get();
The result of this query is in json format:
[
{
"abilities": "[\"rol:user\"]"
}
]
And I thought that the str_replace() function might be my solution, to remove everything else and just leave 'role:user', so I applied it.
$resultado = str_replace('{["\"/:abilities','',$permiso);
This was my result:
"[{\"abilities\":\"[\\\"rol:user\\\"]\"}]"
What I want is that it only remains: role: user
Additional Information:
Result of:
$permission = json_decode($permission,true);
$result = var_dump($permission);
array(1){
[
0
]=>array(1){
[
"abilities"
]=>string(12)"["rol: user"]"
}
}{}
Test
json_decode($permiso);