3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* jobTitle.php Ideally, the model layer is used to access database data More directly generate the desired result array to be returned with loadColumn(): public function getOptions() { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('jobtitle')->from('#__jobs'); return $db->setQuery($query)->loadColumn(); } Ideally, collecting submitted data should be done in the controller layer. Ideally, generating html markup should be done in the view layer. --- technologies.php Use loadResult(): $backend = $db->setQuery($query)->loadResult(); The foreach body can be simplified: foreach ($backend as $line) { $result[] = [$line, in_array($line, $currentBackend)]; } You don't need to increment your own counter. Employ D.R.Y. coding regarding the if block. sprintf() spares interpolation/concatenation. Again, I would rather this mark up be generated in the view layer. $html = '<fieldset id="jform_technologies" class="list checkboxes">'; foreach ($this->getOptions() as $i => [$line, $checked]) { $html .= sprintf( '<label for="%1$s" class="checkbox"> <input type="checkbox" id="%1$s" name="jform[technologies][]" value="%2$s"%3$s>%2$s </label>', 'jform_backend' . $i, $line, $checked ? ' checked' : '' ); } $html .= '</fieldset>'; return $html; */
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

preferences:
137.55 ms | 402 KiB | 149 Q