freshUser
12-16-2010, 12:49 AM
Hi,
i can't find the mistake in my little script hope someone can help me.
<?php
/* -------------------- read thumbfolder -------------------- */
function isRdyPfD($filename){
if ($filename == '.' || $filename == '..') {
// To-Top-Dir
return false;
}
$ext = explode(".",$filename);
$ext = $ext[sizeof($ext) - 1];
$allowedformats = array (
'jpg',
'png',
'jpeg',
'gif'
);
return in_array($ext,$allowedformats);
}
function getPicsfromDir($dir){
/* array with names of the pictures in $dir */
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
$filearray = array();
while (($file = readdir($dh)) !== false) {
if (isRdyPfD($file) === true) {
$filearray[] = $file;
}
}
closedir($dh);
return $filearray;
}
}
else {
return false;
}
} // End Function
$thumbs = getPicsfromDir("./images/thumbs/");
/* -------------------- thumbfolder -------------------- */
echo "<div id='thumbslider'>\n";
echo "<ul id='thumbs'>\n";
for($i = 0; $i < count($thumbs); $i++){
echo "<li><img src=\"./images/thumbs/$thumbs[$i]\" onclick=\"thumbClick($i)\" /></li>\n";
}
echo "</ul>\n";
echo "</div>\n";
/* -------------------- big size images folder -------------------- */
$bigSizeImages = getPicsfromDir("./images/");
//print_r($bigSizeImages);
$jsValue = '';
for ($j=0; $j < count($bigSizeImages); $j++){
$jsValue = $jsValue . $bigSizeImages[$j];
if ($j < (count($bigSizeImages)-1)) {
$jsValue = $jsValue . ",";
}
}
?>
<script type="text/javascript">
images = new Array(<?php echo $jsValue ?>);
function thumbClick(pos){
//alert(pos);
alert(images[pos]);
}
</script>
I can't trace the images array values?
thanks for a feedback!!!
i can't find the mistake in my little script hope someone can help me.
<?php
/* -------------------- read thumbfolder -------------------- */
function isRdyPfD($filename){
if ($filename == '.' || $filename == '..') {
// To-Top-Dir
return false;
}
$ext = explode(".",$filename);
$ext = $ext[sizeof($ext) - 1];
$allowedformats = array (
'jpg',
'png',
'jpeg',
'gif'
);
return in_array($ext,$allowedformats);
}
function getPicsfromDir($dir){
/* array with names of the pictures in $dir */
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
$filearray = array();
while (($file = readdir($dh)) !== false) {
if (isRdyPfD($file) === true) {
$filearray[] = $file;
}
}
closedir($dh);
return $filearray;
}
}
else {
return false;
}
} // End Function
$thumbs = getPicsfromDir("./images/thumbs/");
/* -------------------- thumbfolder -------------------- */
echo "<div id='thumbslider'>\n";
echo "<ul id='thumbs'>\n";
for($i = 0; $i < count($thumbs); $i++){
echo "<li><img src=\"./images/thumbs/$thumbs[$i]\" onclick=\"thumbClick($i)\" /></li>\n";
}
echo "</ul>\n";
echo "</div>\n";
/* -------------------- big size images folder -------------------- */
$bigSizeImages = getPicsfromDir("./images/");
//print_r($bigSizeImages);
$jsValue = '';
for ($j=0; $j < count($bigSizeImages); $j++){
$jsValue = $jsValue . $bigSizeImages[$j];
if ($j < (count($bigSizeImages)-1)) {
$jsValue = $jsValue . ",";
}
}
?>
<script type="text/javascript">
images = new Array(<?php echo $jsValue ?>);
function thumbClick(pos){
//alert(pos);
alert(images[pos]);
}
</script>
I can't trace the images array values?
thanks for a feedback!!!