So I am trying to create a next and previous buttons on my website and I thought I approach it in a rather generic way. I named each of my pages like this:
1.php 2.php 3.php
and so on
So figuratively speaking, while on 2.php, the previous link would point to 1.php and the next link would point to 3.php.
To automate this process on all pages, I am trying to come up with a simple code to add 1 and minus 1 from the current filename.
So in PHP, I did this:
<?php
$dir = $_SERVER['PHP_SELF'];
$dirchunks = explode("/", $dir);
$current = $dirchunks[3];
?>
$current echos out 2.php, the page I am on, is there anyway to add 1 or minus 1 while keeping the .php intacted with the variable $current? so $current 2.php would change to 3.php and 1.php?
I hope my question wasn't confusing and someone can shed some light on my situation. Thanks for the help!
$current - 1and$current + 1? Or am I misunderstanding the question?$current="1.php";$current=$current+1; $current=$current.'php';"1.php" + 1 == 0