Skip to content

Commit

Permalink
convert for() to foreach()
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce Bannon committed Nov 28, 2024
1 parent 402a92a commit 62efa28
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions access.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,20 @@
<option value="__default__"'
. ( $guser == '__default__' ? $selected : '' )
. '>' . $defConfigStr . '</option>';
for( $i = 0, $cnt = count( $userlist ); $i < $cnt; $i++ ) {

foreach ( $userlist as $i ) {
echo '
<option value="' . $userlist[$i]['cal_login'] . '"'
. ( $guser == $userlist[$i]['cal_login'] ? $selected : '' )
. '>' . $userlist[$i]['cal_fullname'] . '</option>';
<option value="' . $i['cal_login'] .
( $guser === $i['cal_login'] ? '" selected>' : '">' ) .
$i['cal_fullname'] . '</option>';
}
for( $i = 0, $cnt = count( $nonuserlist ); $i < $cnt; $i++ ) {

foreach ( $nonuserlist as $i ) {
echo '
<option value="' . $nonuserlist[$i]['cal_login'] . '"'
. ( $guser == $nonuserlist[$i]['cal_login'] ? $selected : '' )
. '>' . $nonuserlist[$i]['cal_fullname'] . ' '
. ( $nonuserlist[$i]['cal_is_public'] == 'Y' ? '*' : '' ) . '</option>';
<option value="' . $i['cal_login'] .
( $guser === $i['cal_login'] ? '" selected>' : '">' ) .
$i['cal_fullname'] . ' ' .
( $i['cal_is_public'] === 'Y' ? '*' : '' ) . '</option>';
}

echo $goStr;
Expand Down Expand Up @@ -294,14 +296,15 @@
. ( $otheruser == '__default__' ? $selected : '' )
. '>' . $defConfigStr . '</option>';

for( $i = 0, $cnt = count( $userlist ); $i < $cnt; $i++ ) {
if( $userlist[$i]['cal_login'] != $guser )
foreach ( $userlist as $i ) {
if ( $i['cal_login'] !== $guser )
echo '
<option value="' . $userlist[$i]['cal_login'] . '"'
. ( ! empty( $otheruser ) && $otheruser == $userlist[$i]['cal_login']
? $selected : '' )
. '>' . $userlist[$i]['cal_fullname'] . '</option>';
<option value="' . $i['cal_login'] .
( ! empty ( $otheruser ) && $otheruser === $i['cal_login']
? '" selected>' : '">' ) .
$i['cal_fullname'] . '</option>';
}

echo $goStr;
}
}
Expand Down Expand Up @@ -475,4 +478,4 @@ function get_list_of_users( $user ) {
return $u;
}

?>
?>

0 comments on commit 62efa28

Please sign in to comment.