2017-08-30 73 views
0

我有話請按代碼是不可改變:得到選項名稱,而不是價值

<select id="_status" name="_status" class="select short"> 
<option value="1">yes</option> 
<option value="2">no</option> 
</select> 

這個代碼,給我的選擇值:

$orc= get_post_meta(get_the_ID(),'_status',true); 

我想要得到「是」或「否」而不是1或2 我將get_post_meta函數更改爲get_option,但dos不起作用 我應該怎麼做?

+0

你永遠可以錄製它,你收到的1 || 2之後 - 如果($獸人== '1'){$獸人=「是'} – Stender

回答

0

你必須使用情況是這樣的:

$orc = (isset($orc) && $orc == 'true') ? 'yes' : 'no'; 
+0

他說,他不能改變html – Stender

+0

然後,他需要把條件如: $ orc =(isset($ orc)&& $ orc =='true')? '是':'不'; –

+0

你應該添加到你的答案。 – Stender

相關問題