2017-02-19 49 views
-1

我有一個數組變量比較關鍵陣列和得到的結果

$usersColor = array 
     ( 
      "nica" => "blue", 
      "rejie" => "red", 
      "evan" => "green" 
     ); 

假設我有這個代碼..

<div class='nica' style="color:(user array color)"> </div> //shoud be the color of nica 

我如何比較和獲得與相應的用戶DIV顏色給定密鑰?

回答

0

只是這樣做,因爲你知道這是nica

<div class='nica' style="color:<?=$usersColor['nica']?>"> </div>