Count json objects in array

Struggling to get the count of all objects in my array to spit out number in json. Can anyone help?

try {
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);   

    $stmt = $conn->prepare('SELECT * FROM date_blocks WHERE user_id = :user_id');
    $stmt->execute(array('user_id' => $user_id));

    while($row = $stmt->fetch()) {
        $startTime = strtotime($row['start_date']);
        $endTime = strtotime($row['end_date']);

        for ($i = $startTime; $i <= $endTime; $i = $i + 86400) {
            $getDate = date('Y-m-d H:i:s', $i); 

} catch(PDOException $e) {
    echo 'ERROR: ' . $e->getMessage();
header('Content-type: application/json');
echo json_encode($return);


Getting the number of elements in JSON format you could do this at the end of your script:

header('Content-type: application/json');
echo json_encode(count($return));

Need Your Help

How to compare two text files with value in ruby

ruby hash compare text-files readlines

I have two text file, and they have one same field(pet). I want to combine two file and output a new file contain three fields(owner pet buyer). My code is mainly depends on if both file have the s...

How to stop centered list from ofsetting to the right

jquery html css

I realise this question has been asked a few times before, but I have a list that is being displayed as an inline block for use as a nav bar. I want the nav bare to be centered on the webpage, and if