php - Update sub fields from repeater with different values in WordPress ACF
I'm trying to update 4 different sub fields from a repeater with 4 different values that i get from a json.
The thing is i'm able to update all the sub fields with a single value(the same for all 4 sub fields), but not with different values.
What I have is: (Sorry i dont know how to add php to the snippet)
Code Link: Link
I've created also an array of the different urls..
$counter = 0; if(have_rows('branch','option')): while(have_rows('branch','option')): the_row();
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'https://www.worldtimeapi.org/api/timezone/Asia/Kuala_Lumpur.json');
$result = curl_exec($ch);
curl_close($ch);
$obj = json_decode($result);
$value = $obj->utc_offset;
update_sub_field('timezone', $value); ?>
<div class="clock-wrapper" data-timezone="<?php the_sub_field('timezone'); ?>">
I have 4 different values I got from the URL:
worldtimeapi.org/api/timezone/Europe/London.json
worldtimeapi.org/api/timezone/Australia/Perth.json
worldtimeapi.org/api/timezone/Europe/Madrid.json
How could I give to each sub field one of the values?