The following is coded in the Laravel framework:
QUERY
$shipping = DB::table('shipping')->where('country',$delivery->country)->first();
$data= json_decode(json_encode($shipping),true);
RESULT
array (
'id' => 3,
'carrier' => 'EN',
'country' => 'AU',
'rates_json' => '{"rates": [{"international": [{"zone4": [{"to_kg": "2", "total": "1", "from_kg": "1"}, {"to_kg": "4", "total": "2", "from_kg": "3"}]}]}]}',
)
In the MySQL database, I stored "rates_json" in a "JSON" datatype column. The attribute "from_kg" and "to_kg" is a range.
I intend to retrieve the total if a value is between the range. For instance, if value 1.5 is between 1 and 2 then the total is 1.
Your help is appreciated.
Thank You.