我有以下if語句:PHP如何把一個if回聲塊內聲明
<?php if (isset ($prfx_stored_meta['wedding-user'])) selected($prfx_stored_meta['wedding-user'][0], 'select-one'); ?>
,我需要插入此回聲聲明:
$users = get_users();
$i = 0;
// Array of WP_User objects.
foreach ($users as $user) {
echo "<option value='select-$i' >" . esc_html($user->display_name) . "</option>";
$i++;
}
如果只是關閉<option>
前標籤
我不知道如何在echo中添加if語句
試試看「三元運算符」:http://www.hackingwithphp.com/3/12/4/the-ternary-operator – arkascha