in the code bellow every time my page is loaded $src becomes a random number. is it possible to incresse $src by one somehow ? so if it become 45 i want it to be incressed by one to 46. <? echo "/flash/loops/".basename($src).""; ?>
check the script bellow. it's a randomizing script a friend gave me. i want $src to become +1 and one place only the rest of the places it's displayed should stay the same number /* The default folder with images */ $settings['img_folder'] = '/var/www/flash/loops/'; /* File types (extensions) to display */ $settings['img_ext'] = array('.jpg','.gif','.png','.swf'); $settings['display_type'] = 0; /* Allow on-the-fly settings override? 0 = NO, 1 = YES */ $settings['allow_otf'] = 1; /* Override type? */ if ($settings['allow_otf'] && isset($_GET['type'])) { $type = intval($_GET['type']); } else { $type = $settings['display_type']; } /* Override images folder? */ if ($settings['allow_otf'] && isset($_GET['folder'])) { $folder = htmlspecialchars(trim($_GET['folder'])); if (!is_dir($folder)) { $folder = $settings['img_folder']; } } else { $folder = $settings['img_folder']; } /* Make sure images fodler ends with an '/' */ if (substr($folder,-1) != '/') { $folder.='/'; } /* Get a list of all the image files */ $flist = array(); foreach($settings['img_ext'] as $ext) { $tmp = glob($folder.'*'.$ext); if (is_array($tmp)) { $flist = array_merge($flist,$tmp); } } /* If we have any images choose a random one, otherwise select the "noimg.gif" image */ if (count($flist)) { $src = $flist[array_rand($flist)]; } else { $src = 'noimg.gif'; } /* Output the image according to the selected type */ if ($type) { header('Location:'.$src); exit(); } else { $fruit = array('apple', 'pear'); $text = 'a p'; $output = str_replace($letters, $fruit, $text); } ?> <? echo "/flash/loops/".basename($src).""; ?> Code (markup):
Replace $src = $flist[array_rand($flist)]; with $src = $flist[array_rand($flist) + 1]; I don't know why you'd want to do that, though.
ah sorry let me remake the question. let's say i have this <? echo "/flash/loops/".basename($src).""; ?> and once the page load $src becomes 55. i want to have another link like this <a href="<? echo "/flash/loops/".basename($plus).""; ?>">next</a> <-- that one should have the +1 to it, so it's 56 insteed.
Simply just add 1 (google "php addition operator") to $src. Heres a quick example <?php $basename = basename($src); $next = $basename + 1; ?> <a href="<?php echo "/flash/loops/".$next; ?>">next</a> PHP: