I currently have a picture page with about 250 jpeg Images and I currently have a web page where I manually assigned a picture to a section on the page, however this is very time consuming and would like to create a script that will run through and assign the images to a div. While this normally would be easy my problem is the way they filed the images. On the web page I have a quad drawling, think of looking down a scope and seeing the circle and cross, 4 section and each section needs a image assigned to it. the image file names vary and is causing my headache:
The file format Ex is below. so each quad would have 4 images, the first set of numbers before the underscore is the pict id and the number in between the underscores is which section of the quad the pict goes to. But the pict id vary in length and I’m not sure how to go about this. Any thoughts or recommendations are appreciated
1234_1_01.jpeg
1234_2_03.jpeg
1234_3_02.jpeg
1234_4_01.jpeg
345422_1_01.jpeg
345422_2_02.jpeg and so on
Im new to php and these are some snipits that i have pieced together without any luck
[php]<?php
$medianView = “IN”;
$fileLoc = $_SERVER[“SCRIPT_NAME”];
$sigID = basename($fileLoc,".php").PHP_EOL;
include("…/…/…/includes/header.php");
?>
$files = scandir($dir);
$images = array();
foreach($files as $file) {
if(fnmatch('*.jpg',$file)) {
$images[] = $file;
}
}
$xp = implode("_", $images);
$thePics = array();
$nameParts = explode('_',$xp);
if(!array_key_exists($nameParts[0],$thePics))$thePics[$nameParts[0]]=array();
$thePics[$nameParts[0]][$nameParts[1]] = $xp;
?>