note 21811 deleted from function.array-slice by dams
| From: | dams@php.net | Date: | Tue, 28 May 2002 19:16:19 +0000 |
| Subject: | note 21811 deleted from function.array-slice by dams | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-31114@lists.php.net to get a copy of this message | ||
Hello guys!!!
If you have to do a next/back navigation system with values in um array! use this something like
that....
<?php
//
// this array $links you can replace with your needs... :)
$links = array (
//
//
// A :: http://weather.yahoo.com/regional/JAXX_A.html
"Akita" => "http://weather.yahoo.com/forecast/JAXX0001.html",
"Akune" => "http://weather.yahoo.com/forecast/JAXX0002.html",
"Amagasaki" => "http://weather.yahoo.com/forecast/JAXX0003.html",
//
//
// B
//
//
//
// C :: http://weather.yahoo.com/regional/JAXX_C.html
//
"Chiba" => "http://weather.yahoo.com/forecast/JAXX0006.html",
"Choshi" => "http://weather.yahoo.com/forecast/JAXX0007.html",
);
// Set here the default limit of offset per time
$offsetdef = 10;
// Count total of cities
$total = count($links);
// Sort the array
ksort($links);
// If $offset ins't set, set it!
if (!isset($offset)) {
$offset = 0;
}
// Slice the array
$links = array_slice($links, $offset,$offsetdef);
// Show here selected slice of array
while (list($city,$url) = each($links)) {
echo "<br>$city ::: $url";
}
// Show next link
$offset+=$offsetdef;
if ($offset<$total) {
echo "<A href=\"$PHP_SELF?offset=$offset\">Next 10</A>\n";
}
// Show back link
$offset-=$offsetdef;
if ($offset>=$offsetdef) {
$offset-=$offsetdef;
echo "<A href=\"$PHP_SELF?offset=$offset\">Back 10</A>\n";
}
?>