<?php
/* assuming you MUST start with your json string, here's my review:
* $i is a useless declaration. You don't use it, so lose it.
* Initialise the $options array by populating it with parent::getOptions().
* In html, when an <option> tag has identical values in its value attribute and its text, the value attribute can be safely removed without any consequence to form or js behaviours.
* I am going to assume/hope that the value element is not required to populate an option tag.
* See you on Tuesday for https://www.meetup.com/Joomla-Users-Group-Brisbane/events/xggwjrybcjbvb/
*/
// COMPLETELY THEORETICAL / UNTESTED...
public function getOptions()
{
$json = '{"items":[{"aliases":["http://www.stackoverflow.com","http://facebook.stackoverflow.com"],"api_site_parameter":"meta.stackoverflow"~}';
$sites = json_decode($json, true);
$options = parent::getOptions();
foreach($sites['items'] as $site)
{
$options[] = ['text' => $site['api_site_parameter']];
}
return $options;
}