Welcome Guest, Not a member yet? Register   Sign In
Entity JSON encode and manually decode
#1

In entity
Code:
protected $casts = [
    'courses'        => 'array',
    'courses_object' => 'json',
    'courses_array'  => 'json-array',
];
The posted array
Code:
courses = array{"bsc-bio", "bsc-bed", "bca"}
It inserted in database as
Code:
"a:3:{i:0;s:7:"bsc-bio";i:1;s:7:"bsc-bed";i:2;s:3:"bca";}"
How to manually decode it?
Code:
json_decode('a:3:{i:0;s:7:"bsc-bio";i:1;s:7:"bsc-bed";i:2;s:3:"bca";}')
json_decode() returns NULL.
Reply


Messages In This Thread
Entity JSON encode and manually decode - by ipmeel - 04-18-2021, 07:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB