note 21811 added to function.array-slice
| From: | evert0n at hotmail dot com | Date: | Tue, 28 May 2002 09:22:22 +0000 |
| Subject: | note 21811 added to function.array-slice | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-31089@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";
}
?>
--
http://www.php.net/manual/en/function.array-slice.php
http://master.php.net/manage/user-notes.php?action=edit+21811
http://master.php.net/manage/user-notes.php?action=delete+21811
http://master.php.net/manage/user-notes.php?action=reject+21811