Re: User listing..
| From: | Oyvind Gronnesby | Date: | Thu, 20 Jul 2000 15:10:23 +0000 |
| Subject: | Re: User listing.. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-7434@lists.php.net to get a copy of this message | ||
stephan.schoell@chhos.mail.abb.com,
>
>
> Oyvind,
>
> You definitely have to loop through the elements of the array $usr (be it a
> string before or not), if you would like to list _all_ the users. The code
> snippet below lists just one or no user... Please refer to my mail earlier this
> afternoon.
We're both wrong. If he doesn't want to print a user in duplicate forms
he needs to check if there are any actual users logged in at all, and
then remove the 'else' in the structure below. Looping through the
elements of the array would give duplicate printouts.
<?php
function dispUsr()
{
if (exec("users", $usr)) {
$usr = explode(" ", $usr);
if (in_array("ben", $usr)) {
echo "<a href='http://www.somesite.org'>Ben</a>";
}
if (in_array("dover", $usr)) {
echo "<a href='http://www.blah.net'>Dover</a>";
}
} else {
echo "No users.";
}
}
I'm not sure if the trick with 'if (exec("users", $usr))' will work and
what 'users' return if nobody is logged on.
I would also put the usernames and the URLs to the users webpages in
their own arrays to make automation easier.
--
Øyvind Grønnesby
"Wow, I had knowledge!"
--Buffy