private function sendNoti($question) { $title = "No title"; $regIds = array(); if (is_array($question)) { if (array_key_exists("title", $question['ForumPost'])) { $title = $question['ForumPost']['title']; } } $admin = $this->Admin->find('all'); foreach ($admin as $arr) { $idstr = $arr['Admin']['gcm_regid']; if (trim($idstr) != null) { $regIds[] = $idstr; } } $this->error_log_array($regIds); $msg = array("title" => $title); if (count($regIds) > 0) { $gcm = new gcm(); $gcm->send_notification($regIds, $msg); } else { error_log("No reg ids found in admin. So GCM cannot be called"); } }