3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '{ "timestamp":1526005337995, "data":[ { "_id":"ByWpiEKaM", "data":"N12E00008", "raw":[78,49,50,69,48,48,48,48,56], "timestamp":1525398457512 } ]}'; $arr = json_decode($json, 1); list($project, $sensor, $percentage) = [substr($arr['data'][0]['data'],0,3), (substr($arr['data'][0]['data'],4,1) == 'E' ? 'Moisture':'Temperature'), substr($arr['data'][0]['data'],-2)]; Var_dump($project, $sensor, $percentage);
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
string(3) "N12" string(11) "Temperature" string(2) "08"

preferences:
48.17 ms | 408 KiB | 5 Q