How to not include jpgs ending _w.jpg in array

images php coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
NigelRen
php-forum Fan User
php-forum Fan User
Posts: 578
Joined: Fri Aug 05, 2011 9:53 am

Re: How to not include jpgs ending _w.jpg in array

Post by NigelRen » Tue Aug 09, 2011 4:16 am

You can easily check if a string ends with a particular value - use substr (http://php.net/manual/en/function.substr.php ) passing a negative value for the start position.

So in your case if you say...

Code: Select all

if ( substr($image,-6) != "_w.jpg" ) {
    echo "slideshow.add('$image');\n";
}
( Although I haven't tried it - so I can't guarantee it is accurate )

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest