本文整理匯總了PHP中EM_Event::to_array方法的典型用法代碼示例。如果您正苦於以下問題:PHP EM_Event::to_array方法的具體用法?PHP EM_Event::to_array怎麽用?PHP EM_Event::to_array使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類EM_Event
的用法示例。
在下文中一共展示了EM_Event::to_array方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getEventPostData
/**
*
* get event post data in array.
* if the post is not event, return empty array
*/
public static function getEventPostData($postID)
{
if (self::isEventsExists() == false) {
return array();
}
$postType = get_post_type($postID);
if ($postType != EM_POST_TYPE_EVENT) {
return array();
}
$event = new EM_Event($postID, 'post_id');
$location = $event->get_location();
$arrEvent = $event->to_array();
$arrLocation = $location->to_array();
$date_format = get_option('date_format');
$time_format = get_option('time_format');
$arrEvent["event_start_date"] = date_format(date_create_from_format('Y-m-d', $arrEvent["event_start_date"]), $date_format);
$arrEvent["event_end_date"] = date_format(date_create_from_format('Y-m-d', $arrEvent["event_end_date"]), $date_format);
$arrEvent["event_start_time"] = date_format(date_create_from_format('H:i:s', $arrEvent["event_start_time"]), $time_format);
$arrEvent["event_end_time"] = date_format(date_create_from_format('H:i:s', $arrEvent["event_end_time"]), $time_format);
$response = array();
$response["start_date"] = $arrEvent["event_start_date"];
$response["end_date"] = $arrEvent["event_end_date"];
$response["start_time"] = $arrEvent["event_start_time"];
$response["end_time"] = $arrEvent["event_end_time"];
$response["id"] = $arrEvent["event_id"];
$response["location_name"] = $arrLocation["location_name"];
$response["location_address"] = $arrLocation["location_address"];
$response["location_slug"] = $arrLocation["location_slug"];
$response["location_town"] = $arrLocation["location_town"];
$response["location_state"] = $arrLocation["location_state"];
$response["location_postcode"] = $arrLocation["location_postcode"];
$response["location_region"] = $arrLocation["location_region"];
$response["location_country"] = $arrLocation["location_country"];
$response["location_latitude"] = $arrLocation["location_latitude"];
$response["location_longitude"] = $arrLocation["location_longitude"];
return $response;
}