J
J
Junior Bee2015-07-07 13:05:09
PHP
Junior Bee, 2015-07-07 13:05:09

Add style to javascript variable?

Hello!
Need help with the following question... there is a javascript timer
codepen.io/juniorCh/pen/GJxQdY
How do I add a class or style to variables to style this timer nicely?
There is not much js knowledge and experience yet. Can someone please tell me how to do this with jQuery?
I would be grateful for any help)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
B
BitRouter, 2018-10-31
@BitRouter

json_encode( $array / $object );
$result = json_decode( $string );
$result = (array)$result;
// read further on how to work with an array (enumerating, mapping, sorting, etc.)

D
DanKud, 2018-10-31
@DanKud

JSON is simply a format for storing an array of information. In any case, the most you can do with JSON is to convert it to an array that the language works with. All other tasks for sorting and obtaining information are already done directly with the resulting array. Just loop through the array to get the data you need into your array:

$json = json_decode($items, true);

$i = 0;
foreach ($json as $data) {
    $input_data_array[$i]['dow_file'] = $data['meta_data'][1]['value'];
    $input_data_array[$i]['obj_name'] = $data['meta_data'][2]['value'];
    $input_data_array[$i]['obj_flat'] = $data['meta_data'][3]['value'];
    $input_data_array[$i]['obj_kad'] = $data['meta_data'][4]['value'];
    /* и так далее.. */
    $i++;
}

print_r($input_data_array);

V
varzin, 2015-07-07
@bee2015

For example like this codepen.io/varzin/pen/rFfhH
Please note that we now display not just values, but frame them with tags. And here we are arranging them with CSS.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question