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

  • SEARCH
  • Home
  • 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 6773243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:38:41+00:00 2026-05-26T15:38:41+00:00

I was able to get some help earlier today, but I didn’t have everything

  • 0

I was able to get some help earlier today, but I didn’t have everything from the original script for it to work. Basically I have a list of image file names in a .txt file. They each load in a slideshow, and change with the pagination on the page.

What I would like to do, is if I have a file that has a .mov extension, for example, the php script will load a movie player instead.

Here is the original slideshow script

<div id='jessslide'>
  <?php
  echo"
<div id='slider-wrapper'>
<div id='slider' class='nivoSlider'>";
  $photos = file("work.txt");
  foreach ($photos as $image) {
    $item = explode("|", $image);
    if ($item[0] == $fields[0]) {
      $photo = trim($item[1]);
      echo"<img src='images/work/$photo' alt='' />\n";
    }
  }
  echo"
</div></div>"
  ?>
</div>

And here is my bad attempt at trying to make this work…

<div id='jessslide'>
  <?php
  $photos = file("work.txt");
  $img = array('jpg', 'png', 'gif');
  $vid = array('swf', 'mp4', 'mov', 'mpg', 'flv');
  foreach ($photos as $image) {
  $item = explode("|", $image);
  if ($item[0] == $fields[0]) {
  $photo = trim($item[1]);
  $ext = explode(".", $image);

  if (in_array($ext[1], $img)) 
  {
  echo "<div id='slider-wrapper'><div id='slider' class='nivoSlider'><img src='images/work/$photo' alt='' /> </div></div>";  
   } 
   elseif (in_array($ext[1], $vid)) 
   {
   echo "<iframe src='$photo' width='800' height='450' frameborder='0' webkitAllowFullScreen allowFullScreen></iframe>";
   }
   }
   }
   ?>
   </div>

I would really appreciate if someone could help me out to finally bring this script to life! 🙂

  • 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-26T15:38:42+00:00Added an answer on May 26, 2026 at 3:38 pm

    The most likely problem I see is the possibility that the assignment to $ext should be tied to $item or $photo instead of $image. If that solves it, then great. Otherwise, read below for a more complete analysis and some suggestions for steps to debug until you narrow in on the cause of the problem.


    Assuming all of the data is accurate, the script you’ve written looks like it should work. I’ve reformatted it here to conduct some analysis:

    <div id='jessslide'>
    <?php
    $photos=file("work.txt");
    $img = array('jpg', 'png', 'gif');
    $vid = array('swf', 'mp4', 'mov', 'mpg', 'flv');
    foreach($photos as $image){
      $item=explode("|",$image);
      if($item[0]==$fields[0]){
        $photo=trim($item[1]);
        $ext = explode(".", $image);
    
        if(in_array($ext[1], $img))
        { echo "<div id='slider-wrapper'><div id='slider' class='nivoSlider'><img src='images/work/$photo' alt='' /> </div></div>"; }
        elseif(in_array($ext[1], $vid))
        { echo "<iframe src='$photo' width='800' height='450' frameborder='0'     webkitAllowFullScreen allowFullScreen></iframe>"; }
      }
    }
    ?>
    </div>
    

    There are three major places in this script for problems to occur that would cause nothing to be output.

    The first is in the foreach() loop. If the $photos array has nothing in it, you would skip the entire block of code. You can test for this condition by adding a print_r($photos); before the foreach() and then as the first line in the body of the foreach() add echo $image." "; to verify that all the files are listed as you expect. If that looks correct, remove that debugging code and move on.

    The 2nd potential for problems is if the $item[0] is not equal to $fields[0]. To test this, add echo 0; as the first line inside if($item[0]==$fields[0]). If you see zeros as expected when the script is run, then you can remove this debugging code and move on.

    The 3rd potential for problems is pull/examination of the extension. One likely candidate for problems here is if the assignment to $ext should be tied to $item or $photo instead of $image but there are definitely other possible issues. To test this, add echo $image." ".$ext[1]."\n"; print_r($img); print_r($vid); before the if(in_array($ext[1], $img)). Then add a temporary else clause with the body of echo 3; as well. Verify that th

    Once you figure out which condition in the code is causing problems, you will be well on the way toward solving it. My guess is that you’ll get through the tests and either find an obvious mistake in one of the early sections that we are assuming works right, or you will end up with 3 being printed out a lot. In the later case, one possible issue could come from lower/upper-case differences, which could be solved via changing the $item assignment to $item=strtolower(explode("|", $image);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks to some help from @Dimitar Christoff I was able to get some Ajax
Thanks to some help from people here, I was able to get my code
I desperately need to be able to get some information from the request array
Hoping I might be able to get some help with an infuriating problem which
I need some help with my code (clearly). So far I'm able to get
I am not able to get my jwysiwyg and Jhtmlarea text editors to work
I am able to get the feed from the spreadsheet and worksheet ID. I
I was able to get this working is SSRS 2008, but do to the
I am able to get nearby places but, how do i draw the places
I am able to get the output format that I need, but not the

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.