在下面的代碼中,如何檢查$variable
是否等於「$ one」。在PHP中獲取變量名稱
<?php
$one = array (1,2,3);
$two = array (4,5,6);
$variables = array ($one, $two);
foreach ($variables as $variable){
//check if the $variable is equal to "$one"
//do stuff that is specific for array $one
}
?>
檢查http://stackoverflow.com/questions/255312/how-to-get-a-variable-name-as-a-string-in-php – Napolux
請澄清你的問題。你想只檢查$ variable是否等於$ 1或不是? 'if($ variable == $ one){//做點事情}' –
'$ variable == $ one'這是不是適合你。數組可以作爲變量進行比較 –