explode() problems, plz help explain

Ok, for fun i decided to try an make a simple image gallery script in php. Using various resources I got it done. I’m using php 5 on a personal web server(for testing purposes) when i upload the script to my real web host, everything just hits the fan…

$images = explode(“n”, dir /b *_thumb.jpg);

this is code that i believe is giving me the problems, on my personal web server it explodes and creates an array with 1 element per line…ie


Now, when i upload to the real web host, it wante to create an array with 4 elements per line…ie

element1 element2 element3 element4
element5 element6 element7 element8

I’ve tried various /'s in the code after dir to fix this, yet nothing seems to be working. I’d appreciate if someone out there might be able to help me out.

You can take a look at the output page here: http://www.wasted-days.net/inc_con it’s a mess, unlike my PWS one, even though they use the same exact code.[/b]

my first question is whether or not your production server supports php5. If it doesn’t then you that might be contributing to your problem.

Another thing you can try is replacing the newline syntax with something else. Try seperating your array data with the | symbol, then use a foreach loop.

$images = explode("|", `dir /b *_thumb.jpg`);

foreach ($images as $show)
echo $show . “



It’s currently running php 4.3.8 I’m not sure how the differences range between those two versions, but I didn’t think it was so much as to give me problems, I’m probable mistaken though.

http://mustuweb.mnsfld.edu/clarkm/imgscript is how the script should look ( this host takes awhile to load, be patient plz ). If anyone wants to look over the code, I’ll be more then happy to post it in a zip or rar someplace.

I tired this instead and tested to see what would be the output, it looks like it has potential but the “|” seperator didn’t have any effect, it was just one long output. I didn’t even think of using a foreach in the original script though, might have to implement that to make a it more efficient.
http://www.wasted-days.net/index.rar here is the full script, be kind to me, i’m still new to php

if you wrote in the OOP style using PHP5 or used some of the new capabilities of php5 then you will definately have problems with your production server. If you used only php4 functions in your program and did it procedurally you should be fine (you can still program OOP in php4 but it is much more limited then 5)

The 4 elements in a row - are they seperated by anything? Can you run another explode on them? Have you tryed to manually create the array (substr, array_push)?

My personal web server is php 5. The host server it doesn’t correctly work on is 4.3.8. I can see why that might cause a problem now. But, the 2nd host server I ran this script on is 4.3.1 and it worked fine. Could there just be some difference between the versions 4.3.1 and 4.3.8 that got disabled, and re-enabled in 5 ?

I appreciate the help by the way. Thanks for taking time out to reply to this post.

Sponsor our Newsletter | Privacy Policy | Terms of Service