PHP Velho Oeste 2024

yp_next

(PHP 4, PHP 5 < 5.1.0)

yp_nextマップから、次のキー/値の組を返す

説明

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

map という名前のマップの中で、指定したキー key の次にある キー/値 の組を返します。

パラメータ

domain

map

key

返り値

次のキー/値 の組を表す配列、あるいはエラー時に FALSE を返します。

例1 NIS next の例

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

if (!
$entry) {
    echo 
"エントリがありません\n";
    echo 
"<!--" yp_errno() . ": " yp_err_string() . "-->";
}

$key key($entry);

echo 
"joe の次のエントリのキーは " $key 
      
"、値は " $entry[$key];
?>

参考

add a note add a note

User Contributed Notes 1 note

up
0
russell dot brown at insignia dot nospam dot com
22 years ago
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;
}
To Top