@fretburner
I have this working code
$res = $this->connection->prepare("....");
$res->bindParam(1,$id);
$res->execute();
$result = $res->fetchAll(PDO::FETCH_ASSOC);
$data = array(
'data'=>$result
);
return json_encode($data);
And this is the result
{“data”:[{“id”:“10”,“time_in”:“2015-07-06 07:30:00”,“time_out”:“2015-07-06 10:26:11”
,“attended”:“yes”},{“id”:“9”,“time_in”:“2015-07-06 08:00:00”,“time_out”:“2015-07-06
11:46:36”,“attended”:“yes”}]}
But I want my result id to have padded 0, how can I achieve to have this output with padded 0
{"data":[{"id":"00010","time_in":"2015-07-06 07:30:00","time_out":"2015-07-06 10:26:11"
,"attended":"yes"},{"id":"00009","time_in":"2015-07-06 08:00:00","time_out":"2015-07-06
11:46:36","attended":"yes"}]}
I know how to put padded 0 if I will use the while loop
str_pad(((int)$row[‘id’]),5,“0”,STR_PAD_LEFT);
but I cannot output same format above.