fetchAll('SELECT id, request_body, created_at FROM webhook_logs ORDER BY created_at DESC LIMIT 20'); foreach ($rows as $r) { $rb = $r['request_body']; $has = strpos($rb, '"messages"') !== false ? 'HAS_MESSAGES' : (strpos($rb, '"statuses"') !== false ? 'ONLY_STATUSES' : 'OTHER'); echo $r['created_at'] . ' | id:' . $r['id'] . ' | ' . $has . PHP_EOL; } } catch (Exception $e) { echo 'ERROR: ' . $e->getMessage() . PHP_EOL; }