Jump to content

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


et4891
Go to solution Solved by 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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.