Can someone help me make 2 changes to my code?

I upload here a PHP file called singhloop.php which works, but I need 2 changes to it:
(1) there is a variable $dir.
Currently the “<a href=” takes the user to a folder which includes the $dir in its path, I need that link to NOT INCLUDE the value of $dir
Example: if $dir = ‘thumbs’ and the code finds a file called h1.jpg in the ‘thumbs’ folder, it currently outputs a link to ‘path-above-p-folder/p/thumbs/h1.php’
CHANGE THIS so that it will be: ‘path-above-p=folder/p/h1.php’
DO THIS by adding a new variable $getfrom to contain the path /p/ which I can edit if I find that I need a different place to fetch .php files from
(2) ADD INLINE CODE so that the link has a hover state that puts a 2px border around the image when hovered-over.
NEEDS TO WORK EQUALLY on all platforms (Windows, Mac, iOS, Android) and all browsers.
= = = = = = = = = = = = = =

<?php // Loop through all images in folder set by variable dir and display them. ?> <?php $dir = 'thumbs'; //Enter your directory name ADDED BY SINGH $path = $dir."/"; // ADDED BY SINGH $images = glob($path."*.{jpg,png,gif,bnp,jpeg}", GLOB_BRACE);

foreach ($images as $image) {
$imageName = preg_replace(’/.[^.\s]{3,4}$/’, ‘’, $image);
$imageFullName = $image;

<?php echo $imageName; ?>
<?php } ?>

Well, if you have a variable that contains the entire pointer to the folder and you want to remove the first directory, you can do it several ways. One easy way is to locate the slash and save just everything after it.
Something loosely like this should work:
$file = “somefolder/somefile.jpg”;
$start = strpos($file, “/”)+1;
$newfile = substr($file, $start);
This will locate the slash and take everything after it. Not tested, just off the top of my head.

Sponsor our Newsletter | Privacy Policy | Terms of Service