Save multi-inputs as nested-array with options.php?

I’m building an admin-page under tools.php and am looping our data and some text fields, I would like to know if it’s possible to save text fields with the same name as nested-array saved to options.php, is it possible?

foreach ($rows as $key => $row){
?>
<div>
<label>
Title
</label>
<input type=”text” name=”option_name[‘<?= $row[‘id’]; ?>’][‘title’]” value=””>
</div>

<div>
<label>
Something
</label>
<input type=”text” name=”option_name[‘<?= $row[‘id’]; ?>’][‘something’]” value=””>
</div>
<?php
}

and then get the array with get_option(‘option_name’) like below

[
‘hello’ => [‘name’ => ‘world’, ‘something’ => ‘123’],
‘world’ => [‘name’ => ‘hello’, ‘something’ => ‘321’]
]

Read more here:: Save multi-inputs as nested-array with options.php?

Leave a Reply

Your email address will not be published. Required fields are marked *