我有一个运行良好的 PHP 代码(wordpress),我只是觉得有一种更聪明的方法可以通过某种数组来缩短整个语法,有人帮忙,代码整洁是第一位的,这里是:
<?php
$user = wp_get_current_user();
// is there someone logged?
if ($user->ID) {
echo '<ul class="availableindex nav nav-pills nav-stacked">';
$n1 = cimy_uef_sanitize_content(get_cimyFieldValue($user->ID, 'NUMBER1'));
$n2 = cimy_uef_sanitize_content(get_cimyFieldValue($user->ID, 'NUMBER2'));
$n3 = cimy_uef_sanitize_content(get_cimyFieldValue($user->ID, 'NUMBER3'));
$n4 = cimy_uef_sanitize_content(get_cimyFieldValue($user->ID, 'NUMBER4'));
$n5 = cimy_uef_sanitize_content(get_cimyFieldValue($user->ID, 'NUMBER5'));
$n6 = cimy_uef_sanitize_content(get_cimyFieldValue($user->ID, 'NUMBER6'));
$n7 = cimy_uef_sanitize_content(get_cimyFieldValue($user->ID, 'NUMBER7'));
$n8 = cimy_uef_sanitize_content(get_cimyFieldValue($user->ID, 'NUMBER8'));
$n9 = cimy_uef_sanitize_content(get_cimyFieldValue($user->ID, 'NUMBER9'));
$n10 = cimy_uef_sanitize_content(get_cimyFieldValue($user->ID, 'NUMBER10'));
echo '<li><a href=# class=dir>' . $n1 . '</a></li>';
echo '<li><a href=# class=dir>' . $n2 . '</a></li>';
echo '<li><a href=# class=dir>' . $n3 . '</a></li>';
echo '<li><a href=# class=dir>' . $n4 . '</a></li>';
echo '<li><a href=# class=dir>' . $n5 . '</a></li>';
echo '<li><a href=# class=dir>' . $n6 . '</a></li>';
echo '<li><a href=# class=dir>' . $n7 . '</a></li>';
echo '<li><a href=# class=dir>' . $n8 . '</a></li>';
echo '<li><a href=# class=dir>' . $n9 . '</a></li>';
echo '<li><a href=# class=dir>' . $n10 . '</a></li>';
echo '</ul>';
}
?>