简体   繁体   English

我需要解析嵌入式Google日历的PHP数组的帮助

[英]I need help parsing a PHP array for an embedded Google Calendar

I'm not sure I'm headed on the right path but what I want to do is have an embedded Google Calendar with multiple calendars encoded in the iframe source. 我不确定自己走的路是正确的,但是我想做的是拥有一个嵌入式Google日历,该日历具有在iframe源中编码的多个日历。 Example: 例:

<iframe src="https://www.google.com/calendar/embed?src=cjvssf4vj98hoa4os5hr26fmcg%40group.calendar.google.com&amp;src=cjvssf4vj98hoa4os5hr26fmcg%40group.calendar.google.com"></iframe>

Notice the two sources (the resource IDs happen to be the same in this example, but in a real scenario they'd be different). 注意这两个来源(在此示例中,资源ID碰巧是相同的,但是在实际情况下它们会有所不同)。 What I want to do now is create an array that would let me put the name of the calendar and its resource ID. 我现在想做的是创建一个数组,该数组可以让我输入日历的名称及其资源ID。 Example: 例:

<?php $rsrcid = array('Some Calendar' => 'cjvssf4vj98hoa4os5hr26fmcg%40group.calendar.google.com',); ?>

And use this array to replace that chunk of src=, etc. so that it's easier to keep track of all these resource ID's (I plan on adding a few dozen). 并使用该数组替换src =等的那一部分,以便更轻松地跟踪所有这些资源ID(我计划添加几十个)。 It would need to have concatenated to it the &src= to each line. 它需要将&src =连接到每一行。 No spaces. 没有空间。 So that it's a long string that I can insert into the iframe src. 因此,这是一个很长的字符串,可以插入iframe src中。

It should be noted I'm not at all good at writing my own PHP, so if I'm even thinking incorrectly please let me know. 应当指出,我一点都不擅长编写自己的PHP,因此,如果我什至没有正确考虑,请告诉我。 Does that make sense? 那有意义吗?

Thanks for reading. 谢谢阅读。

I think I solved this with foreach: 我想我用foreach解决了这个问题:

        <?php
        foreach ($rsrcid as $name => $id){
          echo '&amp;src=' . $id;
        }
        ?>

/noob /菜鸟

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM