0
我與谷歌的字體數組創建一個新的數組(+600):PHP如何從一個數組
$google_fonts = array(
"ABeeZee" => "ABeeZee",
"Abel" => "Abel"
//......)
我需要這種新的結構:
$google_fonts = array(
array('label' => 'ABeeZee','value' => 'ABeeZee'),
array('label' => 'Abel','value' => 'Abel')
//......)
我有這樣的代碼但它不工作:
foreach($google_fonts as $font) {
$google_fonts_array = array(
'value' => $font,
'label' => $font,
'src' => ''
);
}
return $google_fonts_array;
這個數組應該用在這裏(這是一個使用選擇框類型):
'choices' => array(//this is one old option
array(
'value' => 'Open Sans',
'label' => 'Open Sans',
'src' => ''
), //and here is how I would retrieve the new array
$google_fonts_array //or even using it instead of the previous level array, it's not working.
)
爲什麼它不起作用?
是的,你的觀點是好的。但它仍然不適合我。如果我直接使用數組的新結構,值將顯示在選擇框中,所以看起來我缺少代碼中的其他內容......可能是「返回」還不夠。我可以嘗試什麼?提前致謝。 – Gerard
我已經修好了。我必須使用'global $ google_fonts_array;'兩次,其中一個在選項的主文件中(缺失),另一個放入有選擇框的函數中。謝謝 :) – Gerard