Have revised my original code. However am still not managing to actually update my original array. When I echo out echo '<pre>'.print_r( $form['fields'][8]['choices'][0]['text'] ).'</pre>';
I am still getting my original array values. Not much of a programmer so thrashing around in the dark a bit.
$form_id = '6';
$form = GFAPI::get_form( $form_id );
foreach ( $form['fields'] as $key => &$field )
{
if (isset( $field['id']) && $field['id'] == 47 )
{
foreach ( $field['choices'] as $key => &$choice )
{
if (isset($choice['value']) && $choice['value'] == 1)
{
$choice['text'] = 'test';
$choice['price'] = '99';
echo '<pre>'.print_r( $choice['text']).'</pre>';
echo '<pre>'.print_r( $choice['price']).'</pre>';
}
}
}
}
echo '<pre>'.print_r( $form['fields'][8]['choices'][0]['text'] ).'</pre>';
$result = GFAPI::update_form( $form );
return $result;
My Answer:
you please provide more context or clarify your question about arrays? Arrays are a data structure in programming that can store multiple values of the same data type in a single variable. They are commonly used to store lists of items or elements. Let me know how I can assist you further with arrays.
Rate this post
5 of 5 based on 7626 votesComments