Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have the following code:

$woo_options = get_option( 'woo_options' ); 
//print_r($woo_options);
$has_updated = false; 

foreach ($options as $value) {
//print_r($value);
update_option( $value['id'], $_REQUEST[ $value['id'] ] ); 
    $key = $value['id'];
    $keyconf = $_REQUEST[ $value['id'] ];

    **echo $woo_options[$key];**

    if ( isset( $woo_options[$key] ) ) {
        $woo_options[$key] = $keyconf;
        $has_updated = true;
        }
}       

if ( $has_updated == true ) {
update_option( 'woo_options', $woo_options );
}

The thing is if I put echo $woo_options[$key]; nothing happens, and with echo $woo_options['woo_author']; with proper quotes, the value shows up... I need this to update a value from an array.

Here's a part of my "print_r($woo_options);"

Array ( [woo_alt_stylesheet] => [woo_logo] => [woo_texttitle] => [woo_font_site_title] => Array ( [size] => 40 [unit] => px [face] => Droid Serif [style] => 300 [color] => #ffffff ) [woo_google_analytics] => [ woo_feed_url] => [woo_subscribe_email] => [woo_comments] => post [woo_post_content] => excerpt [woo_author] => false...

Note: The $key var is showing up: woo_alt_stylesheet, woo_logo, woo_texttitle... as wanted...

share|improve this question
    
How about $woo_options[''.$key.''];, what does happen then? (isn't a real solution) –  Dennis Hunink Jan 29 '13 at 13:39
    
nothing happens :( –  thiagovinicius Jan 29 '13 at 13:51
add comment

3 Answers 3

What happens if you trim your $key value?

$key = trim($value['id']);
share|improve this answer
    
nothing happens... –  thiagovinicius Jan 29 '13 at 13:48
add comment

what is your $options variable in the foreach? Shouldn't it be $woo_options?

share|improve this answer
    
as I said, the $key var is showing up all the names correctly... –  thiagovinicius Jan 29 '13 at 13:49
    
$options = array ( array( "name" => "Configurações", "type" => "title"), array( "type" => "open"), array( "name" => "Estilo de Cor", "desc" => "Escolha o Estilo de Cor de seu site", "id" => $shortname."_alt_stylesheet", "std" => "", "type" => "select", "options" => $alt_stylesheets), –  thiagovinicius Jan 29 '13 at 13:49
add comment
up vote 0 down vote accepted

I solved it using a function to compare two arrays and then update the "different" indexes... more info, contact me.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.