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 8229191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:42:57+00:00 2026-06-07T16:42:57+00:00

I tested this on firefox and it works fine, but in IE it doesn’t

  • 0

I tested this on firefox and it works fine, but in IE it doesn’t work because of comma on last part of array. Now how can I remove comma using php?

Actual result:

{image : 'folder/pic1.jpg', title : '', thumb : 'folder/pic1.jpg', url : ''},
{image : 'folder/pic2.jpg', title : '', thumb : 'folder/pic2.jpg', url : ''},
{image : 'folder/pic3.jpg', title : '', thumb : 'folder/pic3.jpg', url : ''},

Expected result:

{image : 'folder/pic1.jpg', title : '', thumb : 'folder/pic1.jpg', url : ''},
{image : 'folder/pic2.jpg', title : '', thumb : 'folder/pic2.jpg', url : ''},
{image : 'folder/pic3.jpg', title : '', thumb : 'folder/pic3.jpg', url : ''}

Code:

<?php 
$directory = "pic/";

$images = glob("".$directory."{*.jpg,*.JPG,*.PNG,*.png}", GLOB_BRACE);

if ($images != false)
{
?>
<script type="text/javascript">
    jQuery(function($){
        $.supersized({
            slideshow:   1,//Slideshow on/off
            autoplay:    1,//Slideshow starts playing automatically
            start_slide: 1,//Start slide (0 is random)
            stop_loop:   0,
            slides:      [// Slideshow Images

            <?php
    foreach( $images as $key => $value){
                 echo "{image : '$value', title : '', thumb : '$value', url : ''},";
            }
            ?>
            ],
            progress_bar: 1,// Timer for each slide
            mouse_scrub: 0
</script>
<?php
}
?>
  • 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-06-07T16:43:00+00:00Added an answer on June 7, 2026 at 4:43 pm

    You don’t need to hand-code your own JSON. Use json_encode()

    echo json_encode($images);
    

    To answer the question nonetheless, there’s two ways of avoiding the trailing comma (which should indeed be removed, even if Firefox et al let you get away with it)

    1 – conditionlise its output in your loop

    $arr = array('apple', 'pear', 'orange');
    foreach($arr as $key => $fruit) {
        echo $fruit;
        if ($key < count($arr) - 1) echo ', ';
    }
    

    Note this will work only for indexed arrays. For associative ones, you’d have to set up your own counter variable (since $key would not be a number).

    2 – remove it afterwards, e.g. with REGEX

    $str = "apple, pear, orange, ";
    $str = preg_replace('/, ?$/', '', $str);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tested this on Firefox, Opera and Seamonkey. It works fine. When it
I had tested this code: http://support.microsoft.com/kb/316383 It works, but a Word application is opened
This site loads fine in Firefox, but in WebKit browsers (Safari and Google Chrome)
My web app works fine on Firefox or Chrome but not in IE. It
This problem only occurs using IE (only tested in IE 7, works fine in
I have tested this servlet and it works well, except in Google Chrome it
I've a string, In sql I've tested this string contains non-printable characters but I
I've made a hover function with jquery. All works fine in FireFox and Chrome,
I create a small page with CSS, when i tested this on Mozilla firefox
Ladies / Gents: Doing a $.post which works fine in Chrome & FireFox. IE

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.