嗨,社區#1。
其實我有looping(while)while while。這就是我所說的分而已。我想從while返回一些值,但是它看起來像是,值不能在一個子集中讀取。
實驗:
- 獲取代碼正常工作。一切都好,除了這$ x;
- 有沒有發現其他錯誤,但全球$ X,不能內部子被打印而
我嘗試使用全局函數聲明,而函數值。儘管如此,全局函數仍然無法在sub中讀取。該代碼是幾乎沒有這樣的:
while (fetch){
$x = value; // multi value, like A, B, C, D, E for example
global $x;
echo $x; // echo print still ok
while (fetch){
echo "<select>". // i use select attribute in this case, it's plus a (.) dot
// so code inside this sub while actually working but $x can't be printed
echo $x; // not print anything
echo "<option" . (($x==$throw[0]) ? 'selected="selected"': '') ."value=".$throw[0].">".$throw[0]."</option>'";
// i use this option attribute, and want $x to be inside the option attribute basically, because it needs to be compared
"</select>";
} // end sub while
} // end while
所需的輸出:
我想在$ X返回值是它,就像在while循環。因爲$ x中的多值將與具有正確顯示的值的$ throw [0]進行比較,而$ x值甚至沒有顯示。
僅供參考,$ X包含例如幾個值,如:A,B,C,d,E
你有任何想法,這是爲什麼發生?我該怎麼做或修改?
謝謝你Stackoverflow社區。
不應該有後選擇()點。回聲「