yp_next

(PHP 3 >= 3.0.7, PHP 4, PHP 5 <= 5.0.4)

yp_next -- Returns the next key-value pair in the named map

Description

array yp_next ( string domain, string map, string key )

yp_next() returns the next key-value pair in the named map after the specified key or FALSE.

例子 1. Example for NIS next

<?php
$entry
= yp_next($domain, "passwd.byname", "joe");

if (!
$entry) {
    echo
"No more entries found\n";
    echo
"<!--" . yp_errno() . ": " . yp_err_string() . "-->";
}

$key = key($entry);

echo
"The next entry after joe has key " . $key
      
. " and value " . $entry[$key];
?>

See also yp_first() and yp_get_default_domain().


add a note add a note User Contributed Notes
russell dot brown at insignia dot nospam dot com
04-Jul-2001 11:45
If you combine yp_first and yp_next you can get the whole list:
function yp_list($domain, $map) {
   $entry = yp_first($domain, $map);
   $key = $entry ["key"];
   $yplist[$key] = $entry ["value"];
  
   while ($entry) {
     $entry = yp_next($domain, $map, $key);
     if ($entry) {
         $nextkey = key ($entry);
         $yplist[$nextkey] = $entry[$nextkey];
         $key = $nextkey;
     }
   }
   return $yplist;
}