Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4251434
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:39:41+00:00 2026-05-21T04:39:41+00:00

I use this PHP/CodeIgniter code to generate events on fullCalendar $(‘#calendar’).fullCalendar({ events: [ <?php

  • 0

I use this PHP/CodeIgniter code to generate events on fullCalendar

$('#calendar').fullCalendar({

        events: [
                <?php foreach($cal_data as $row): ?>
                    {   
                  title : '<?php echo $row->pt_name . ' ' . $row->value_2; ?>',
                  start : '<?php echo $row->date . 'T' . $row->time .'Z'; ?>',
                  url   : '<?php echo base_url() . 'events/events_edit/' . $row->record_id; ?>',
                  color: '<?php echo $row->value_4; ?>'
                    }, //  <=== this comma is the problem
                <?php endforeach; ?>
                ],
etc...

As you can see on line 10 there is that final comma which will close the event data, and the loop goes on. A typical output will be:

events: [
        {   
              title : 'Test1',
          start : '2011-04-07T08:45:00Z',
          url   : http://example.com/events/events_edit/81',
          color: '#ed9d2b'
                        },
        {   
          title : 'Test2',
          start : '2011-04-09T08:45:00Z',
          url   : http://example.com/events/events_edit/82',
          color: '#ed9d2b'
                        }, // <======= trailing comma

Unfortunately the trailing comma from the last event breaks the render on IE8 (events show nicely on Cr, FF, Saf).

Any suggestions on how to resolve this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T04:39:41+00:00Added an answer on May 21, 2026 at 4:39 am

    It looks like you’re building JSON. Why not actually, say, build JSON? Alter your code to build a multi-dimensional array instead of output. You’d want a structure like

    $stuff = array(
        'events' => array(
            0 => array(
                'title' => ...,
                'start' => ...
                'url' => ...
                'color' => ...
            ),
            // etc
        ),
        // etc
    ));
    

    By building the data separately from emitting it, you can ensure you have it correct to begin with, and let the JSON encoder worry about the syntax:

    $('#calendar').fullCalendar(<?php echo json_encode($stuff); ?>);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The class I wish to use is: https://github.com/philsturgeon/codeigniter-curl/blob/master/libraries/Curl.php How can I use this in
To grab the inode of a file in PHP, you can use this: $fs
This question is simple. What function would I use in a PHP script to
Please how can I use spl_autoload_register() with Codeigniter? I need to do this because
I want to use objects(java style) in my PHP code after by instantiating objects
I have something like the following code in one of my views: <?php $this->load->view('_validation_error',
When is it a good idea to use PHP_EOL ? I sometimes see this
I use this tool called Lazy C++ which breaks a single C++ .lzz file
I use this line in my .htaccess file to automatically add a trailing slash
Can I use this approach efficiently? using(SqlCommand cmd = new SqlCommand(GetSomething, new SqlConnection(Config.ConnectionString)) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.