Jump to content

how to properly json decode and use the key/value?


et4891

Recommended Posts

I have three text box for people to enter as numbers and stores in json

<?php add_option('angels_'.date("ymd-His"), json_encode($_POST)); ?>

The data stored in the database looks like

{"angle1":"60","angle2":"60","angle3":"90","submit":"Submit"}

the above is also what I get what I called out the data from the database

I used this code to call out the data

<?php
$sql = "SELECT * FROM wp_options WHERE option_name LIKE 'angels%' ORDER BY option_name";
$options = $wpdb->get_results($sql);
foreach ( $options as $option ) {
     esc_attr($option->option_value).PHP_EOL;
}
    $values = esc_attr($option->option_value);

    echo $values;
?>

The output gives me

{"angle1":"60","angle2":"60","angle3":"90","submit":"Submit"}

if I only want to get the numbers 60/60/90 individually how can I do that?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.