Greetings,
I have an array to output a dropdown menu from a database that fails with the error "Cannot use string offset as an array". I'm using PHP 5 and I'm not sure how to change the function to be compatible.
Here's the string:
function tep_get_source_list($name, $show_other = false, $selected = '', $parameters = '')
"$show_other = false" is the offender. The intent is to have a dropdown menu where people can select which search engine they came from, or choose "other" to enter the information into a text field.
Here's the code:
function tep_get_source_list($name, $show_other = false, $selected = '', $parameters = '') {
$sources_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
$sources = tep_get_sources();
for ($i=0, $n=sizeof($sources); $i<$n; $i++) {
$sources_array[] = array('id' => $sources[$i]['sources_id'], 'text' => $sources[$i]['sources_name']);
}
if ($show_other == 'true') {
$sources_array[] = array('id' => '9999', 'text' => PULL_DOWN_OTHER);
}
return tep_draw_pull_down_menu($name, $sources_array, $selected, $parameters);
}
Help is much apreciated
I have an array to output a dropdown menu from a database that fails with the error "Cannot use string offset as an array". I'm using PHP 5 and I'm not sure how to change the function to be compatible.
Here's the string:
function tep_get_source_list($name, $show_other = false, $selected = '', $parameters = '')
"$show_other = false" is the offender. The intent is to have a dropdown menu where people can select which search engine they came from, or choose "other" to enter the information into a text field.
Here's the code:
function tep_get_source_list($name, $show_other = false, $selected = '', $parameters = '') {
$sources_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
$sources = tep_get_sources();
for ($i=0, $n=sizeof($sources); $i<$n; $i++) {
$sources_array[] = array('id' => $sources[$i]['sources_id'], 'text' => $sources[$i]['sources_name']);
}
if ($show_other == 'true') {
$sources_array[] = array('id' => '9999', 'text' => PULL_DOWN_OTHER);
}
return tep_draw_pull_down_menu($name, $sources_array, $selected, $parameters);
}
Help is much apreciated