【发布时间】:2011-12-23 18:36:49
【问题描述】:
我正在处理主题选项页面并尝试将css 密钥发送到我的php css 文件。我可以从父数组中选择array key,但我不知道如何从子集中获取css key。任何人都可以帮助我吗?我对php 很陌生,并且正在努力学习。
谢谢!
$fonts = array(
'Arial' => array(
'name' => 'Arial',
'font' => '',
'css' => "font-family: Arial, sans-serif;"
),
'ubuntu' => array(
'name' => 'Ubuntu',
'font' => '@import url(http://fonts.googleapis.com/css?family=Ubuntu);',
'css' => "font-family: 'Ubuntu', sans-serif;"
),
'lobster' => array(
'name' => 'Lobster',
'font' => '@import url(http://fonts.googleapis.com/css?family=Lobster);',
'css' => "font-family: 'Lobster', cursive;"
),
'Lato' => array(
'name' => 'Lobster',
'font' => '@import url(http://fonts.googleapis.com/css?family=Lato);',
'css' => "font-family: 'Lato', sans-serif;"
),
'Droid Sans' => array(
'name' => 'Droid Sans',
'font' => '@import url(http://fonts.googleapis.com/css?family=Droid+Sans);',
'css' => "font-family: 'Droid Sans', sans-serif;"
),
'Tachoma' => array(
'name' => 'Tachoma',
'font' => '',
'css' => "font-family: Tachoma, Geneva, sans-serif;"
),
'Verdana' => array(
'name' => 'Verdana',
'font' => '',
'css' => "font-family: Verdana, Verdana, Geneva, sans-serif;"
),
'Times New Roman' => Array(
'name' => 'Times New Roman',
'font' => '',
'css' => "font-family: Times New Roman, Times New Roman, serif;"
),
'Georgia' => array(
'name' => 'Georgia',
'font' => '',
'css' => "font-family: Georgia, serif;"
),
'Custom Font' => array(
'name' => $custom_family,
'font' => $custom_font,
'css' => "font-family:" . $custom_family . "sans-serif;",
)
);
$custom_font = get_option('ideate_custom_font');
//Extract the values from the URL String that are separated by '='
$name_extract = explode('=', $custom_font);
//Find these characters in the URL string
$find = array("+", ");");
//Add Space or Null the value
$replace = array(" ","");
//Take the Family Value from the String and Remove any Special Characters from 'Find' array
$custom_family_string = str_replace($find,$replace,$name_extract[1]);
//Take Value from String Replacement and Add Quotes Around it
$custom_family = "\"" .$custom_family_string. "\"";
$font_array = array_keys($fonts);
【问题讨论】:
标签: php arrays key multidimensional-array