In my functions.php file I've created an options page for WordPress admin which is working fine.
I've got a bunch of fields and I can retrieve the values that are saved and display them on my options page, like this one for example:
$options = get_option( 'flight_settings' );
<input name="passenger_name" value="<?php if($options['passenger_name']) { echo esc_attr_e( $options['passenger_name'] ); } ?>" />
But now I need to take it further and I've hit a road block.
Using this method I can now create additional fields, which can be spawned like...
<input name="passenger_name_1" id="passenger_name_1" value="" />
<input name="passenger_name_2" id="passenger_name_2" value="" />
<input name="passenger_name_3" id="passenger_name_3" value="" />
...and so on, which no limit to how many additional fields you can spawn. This works perfectly fine and when I save the settings the data is being stored in the database (in "flight_settings" option_name with all the correct option values.)
The Actual Problem
The problem I now have is how do I retrieve the stored values without knowing exactly what I'm looking for? With just a single field it's easy because I know the exact name of what I'm looking for (passenger_name for example as mentioned above).
But if 20 fields were spawned and saved, then ideally I would see all 20 fields displayed on my options page.
I'm guessing the answer is something along the lines of a custom loop that looks for all option field names that are similar to passenger_name. But maybe I'm nowhere near on the right track?
Thanks in advance.