scottybwoy Posted November 3, 2008 Share Posted November 3, 2008 Is it possible to put functions in an array? i.e. if (tep_db_num_rows($filterlist_query) > 1) { $info_box_contents[] = array( array('text' => tep_draw_form('filter', FILENAME_DEFAULT, 'get') if (isset($HTTP_GET_VARS['manufacturers_id'])) { echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']); $options = array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES)); } else { echo tep_draw_hidden_field('cPath', $cPath); $options = array(array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS)); } echo tep_draw_hidden_field('sort', $HTTP_GET_VARS['sort']); while ($filterlist = tep_db_fetch_array($filterlist_query)) { $options[] = array('id' => $filterlist['id'], 'text' => $filterlist['name']); } echo tep_draw_pull_down_menu('filter_id', $options, (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''), 'onchange="this.form.submit()"'); echo '</form>'; }, array('text' => "<label for='pfrom' class='fieldKey'>" . Cost . "</label>" . echo tep_draw_input_field('pfrom', ENTRY_PRICE_FROM, 'class="fieldValue"') . echo tep_draw_input_field('pto', ENTRY_PRICE_TO, 'class="fieldValue"'))), }; } Quote Link to comment https://forums.phpfreaks.com/topic/131219-solved-functions-in-arrays/ Share on other sites More sharing options...
kenrbnsn Posted November 3, 2008 Share Posted November 3, 2008 Why? Ken Quote Link to comment https://forums.phpfreaks.com/topic/131219-solved-functions-in-arrays/#findComment-681244 Share on other sites More sharing options...
DarkWater Posted November 3, 2008 Share Posted November 3, 2008 1) Why are you using $HTTP_GET_VARS instead of the superglobal $_GET? 2) What do you mean by 'put functions in an array'? >_< Quote Link to comment https://forums.phpfreaks.com/topic/131219-solved-functions-in-arrays/#findComment-681246 Share on other sites More sharing options...
scottybwoy Posted November 3, 2008 Author Share Posted November 3, 2008 Sorry, I'm editing some code thats in my OsCommerce site, and it uses its own templating engine that uses arrays to lay sections out. What it is doing is choosing one part of data or another to go in the array cell. Thats why I want the If statements in there. Sorry I meant If statements not functions. But it doesn't seem to like it. Any ideas of ways around it? Quote Link to comment https://forums.phpfreaks.com/topic/131219-solved-functions-in-arrays/#findComment-681275 Share on other sites More sharing options...
corbin Posted November 3, 2008 Share Posted November 3, 2008 $array = array('SomeKey' => func()); Or to answer your new question: $array = array(); if() { $array['SomeKey'] = "something"; } else { $array['SomeKey'] = "something else"; } Or, this might work (untested, but theoretical): $array = array( 'SomeKey' => (<some condition) ? "something" : "something else", ); Doubt that will work though. Quote Link to comment https://forums.phpfreaks.com/topic/131219-solved-functions-in-arrays/#findComment-681550 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.