从PHP键获取值

从PHP键获取值,php,Php,出于速度原因,我有一个冗长的值数组,没有解释键。这些键将自动填充为数字键0-N: $array = array('Good old days', 'Bad old days', ....); 表单中填写了预期的键值对: key=0, value=Good old days 或 我似乎被“价值观”迷住了 更新2,以防对任何人有用或有任何改进: $gwf_settings = array( 'base_font', 'artic

出于速度原因,我有一个冗长的值数组,没有解释键。这些键将自动填充为数字键0-N:

$array = array('Good old days', 'Bad old days', ....);
表单中填写了预期的键值对:

key=0, value=Good old days

我似乎被“价值观”迷住了

更新2,以防对任何人有用或有任何改进:

          $gwf_settings = array(
            'base_font',
            'article_title',
            'site_name',
            'site_slogan',   
          );

          $gwf_gwf = array(
            'base_font_gwf',
            'article_title_gwf',
            'site_name_gwf',
            'site_slogan_gwf',   
          );  

          foreach($gwf_settings as $key => $gwf_font) {     
            if ( theme_get_setting($gwf_font) == 'gwf' ) {       
              $gwfs = array();
              foreach ($gwf_gwf as $k => $gwf_setting) {   
                $s = theme_get_setting($gwf_setting);         
                $fonts = get_gwf();     
                if ( $s ) { 
                  foreach ($fonts as $f => $val) {
                    if ( $f == $s ) {                 
                      $gwfs[] = str_replace(' ', '+',  $val);
                    }
                  }
                }
              }
            }
          }   

          $google_web_fonts = implode('|', $gwfs); 

        // The final output will be just like with wordy key version: 
//http://fonts.googleapis.com/css?family=Oswald|Yanone+Kaffeesatz|Droid+Sans

如果您有钥匙,您可以使用它:


echo$array[0]
将打印“过去的美好时光”。

您是指$array[key]以外的内容吗?我想我需要为“其他内容”再做两个循环,我必须为设置再做一个循环,最后为字体再做一个循环,willy nilly:)。谢谢你一直以来的提示
  //If keys are wordy: http://fonts.googleapis.com/css?family=Quattrocento|Droid+Sans|Yanone+Kaffeesatz

  $gwf_settings = array(
    'base_font',
    'article_title',
    'site_name',
    'site_slogan',   
  );


  $gwfs = array();
  foreach($gwf_settings as $key => $gwf_font) { 
    //dsm('KEYS: '. $key); 
    // parent form to check condition if we are using gwf
        if (theme_get_setting($gwf_font) == 'gwf') {
          $values = $gwfs[theme_get_setting($gwf_font .'_gwf')];
            dsm('KEY2: '. theme_get_setting($gwf_font .'_gwf')); //ok, we have the gwf key
            dsm('VALUES: '. $values); // BLANK        
$gwfs[] = str_replace(' ', '+',  $values);
        }       
  }    

  $google_web_fonts = implode('|', $gwfs);
          $gwf_settings = array(
            'base_font',
            'article_title',
            'site_name',
            'site_slogan',   
          );

          $gwf_gwf = array(
            'base_font_gwf',
            'article_title_gwf',
            'site_name_gwf',
            'site_slogan_gwf',   
          );  

          foreach($gwf_settings as $key => $gwf_font) {     
            if ( theme_get_setting($gwf_font) == 'gwf' ) {       
              $gwfs = array();
              foreach ($gwf_gwf as $k => $gwf_setting) {   
                $s = theme_get_setting($gwf_setting);         
                $fonts = get_gwf();     
                if ( $s ) { 
                  foreach ($fonts as $f => $val) {
                    if ( $f == $s ) {                 
                      $gwfs[] = str_replace(' ', '+',  $val);
                    }
                  }
                }
              }
            }
          }   

          $google_web_fonts = implode('|', $gwfs); 

        // The final output will be just like with wordy key version: 
//http://fonts.googleapis.com/css?family=Oswald|Yanone+Kaffeesatz|Droid+Sans
$array[$key]