1 回答

TA貢獻(xiàn)1773條經(jīng)驗(yàn) 獲得超3個(gè)贊
一個(gè)短的班輪...
$data = [
? ? 75 => 'END:DAYLIGHT',
? ? 76 => 'BEGIN:STANDARD',?
? ? 77 => 'DTSTART:20211031T030000',
? ? 78 => 'TZOFFSETFROM:+0300',?
? ? 79 => 'TZOFFSETTO:+0200',?
? ? 80 => 'TZNAME:EET',?
? ? 81 => 'END:STANDARD',
? ? 82 => 'END:VTIMEZONE',
? ? 83 => 'BEGIN:VEVENT',
? ? 84 => 'SUMMARY:',
? ? 85 => 'DESCRIPTION: Tourist Agent Office: First Name: Last Name: Email: xxx@gma',
? ? 86 => 'il.com Visitors: 1 Phone: Details: Time Slots: 12:00 μμ - 11:59 πμ',?
? ? 87 => '',
? ? 88 => 'DTSTART:20200711T120001',
? ? 89 => 'DTEND:20200725T115902',?
? ? 90 => 'UID:2020-07-11 12:00:01_25@demo.icalendar.org',?
? ? 91 => 'DTSTAMP:20200604T130218',
? ? 92 => 'CREATED:20200129T104306',?
? ? 93 => 'LAST-MODIFIED:20200129T104306',
? ? 94 => 'STATUS:CONFIRMED',
? ? 95 => 'END:VEVENT',?
? ? 96 => 'BEGIN:VEVENT',?
? ? 97 => 'SUMMARY:',
? ? 98 => 'DESCRIPTION: Tourist Agent Office: First Name: Last Name: Email: xxx@gma',?
? ? 99 => 'il.com Visitors: 1 Phone: Details: Time Slots: 12:00 μμ - 11:59 πμ',
? ? 100 => '',
? ? 101 => 'DTSTART:20200912T120001',
? ? 102 => 'DTEND:20200926T115902',
? ? 103 => 'UID:2020-09-12 12:00:01_26@demo.icalendar.org',
? ? 104 => 'DTSTAMP:20200604T130218',?
? ? 105 => 'CREATED:20200203T060059',
? ? 106 => 'LAST-MODIFIED:20200203T060059',
? ? 107 => 'STATUS:CONFIRMED',
? ? 108 => 'END:VEVENT',
? ? 109 => 'END:VCALENDAR',
];
$result = array_slice($data, array_search('BEGIN:VEVENT', array_values($data)) ?: 0);
var_dump($result);
函數(shù)array_search搜索 的第一次出現(xiàn)BEGIN:VEVENT
并返回找到的偏移量,用array_values識(shí)別原始數(shù)組的值。您可以將此鍵用作array_slice函數(shù)的偏移量,該函數(shù)返回?cái)?shù)組的其余部分。
如果BEGIN:VEVENT
給定數(shù)組中不存在,則將返回整個(gè)數(shù)組。
上述示例的結(jié)果:
array(27) {
? ? [0] => string(12) "BEGIN:VEVENT"
? ? [1] => string(8) "SUMMARY:"
? ? [2] => string(72) "DESCRIPTION: Tourist Agent Office: First Name: Last Name: Email: xxx@gma"
? ? [3] => string(70) "il.com Visitors: 1 Phone: Details: Time Slots: 12:00 μμ - 11:59 πμ"
? ? [4] => string(0) ""
? ? [5] => string(23) "DTSTART:20200711T120001"
? ? [6] => string(21) "DTEND:20200725T115902"
? ? [7] => string(45) "UID:2020-07-11 12:00:01_25@demo.icalendar.org"
? ? [8] => string(23) "DTSTAMP:20200604T130218"
? ? [9] => string(23) "CREATED:20200129T104306"
? ? [10] => string(29) "LAST-MODIFIED:20200129T104306"
? ? [11] => string(16) "STATUS:CONFIRMED"
? ? [12] => string(10) "END:VEVENT"
? ? [13] => string(12) "BEGIN:VEVENT"
? ? [14] => string(8) "SUMMARY:"
? ? [15] => string(72) "DESCRIPTION: Tourist Agent Office: First Name: Last Name: Email: xxx@gma"
? ? [16] => string(70) "il.com Visitors: 1 Phone: Details: Time Slots: 12:00 μμ - 11:59 πμ"
? ? [17] => string(0) ""
? ? [18] => string(23) "DTSTART:20200912T120001"
? ? [19] => string(21) "DTEND:20200926T115902"
? ? [20] => string(45) "UID:2020-09-12 12:00:01_26@demo.icalendar.org"
? ? [21] => string(23) "DTSTAMP:20200604T130218"
? ? [22] => string(23) "CREATED:20200203T060059"
? ? [23] => string(29) "LAST-MODIFIED:20200203T060059"
? ? [24] => string(16) "STATUS:CONFIRMED"
? ? [25] => string(10) "END:VEVENT"
? ? [26] => string(13) "END:VCALENDAR"
}
- 1 回答
- 0 關(guān)注
- 140 瀏覽
添加回答
舉報(bào)