第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何從特定值之前的數(shù)組中刪除所有值

如何從特定值之前的數(shù)組中刪除所有值

PHP
慕絲7291255 2023-04-28 16:01:08
我有以下數(shù)組,我需要?jiǎng)h除鍵 83 之前的所有值,值為 BEGIN:VEVENT。我需要的不是按鍵,而是僅使用值。   Array ( [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 [110] =>)到目前為止我已經(jīng)嘗試過(guò)...$result = array_slice($array, array_search('BEGIN:VEVENT', $array) ?: 0); print_r($array);其中 $array 是上面的例子這將返回相同的數(shù)組
查看完整描述

1 回答

?
慕容3067478

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"

}


查看完整回答
反對(duì) 回復(fù) 2023-04-28
  • 1 回答
  • 0 關(guān)注
  • 140 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)