in_array function

From: Date: Thu, 10 Apr 2003 22:37:59 +0000
Subject: in_array function
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-9212@lists.php.net to get a copy of this message
Just tried creating my first custom function. very simple in_array() Wonder though, this seems to be too complex for what I'm doing. I'm just print a alpha menu where only letters with results are hyperlinked. Is there anything I should do differently? /* load the abc's */ $smarty->assign('abc',array('A','B','C','D','E')); /* array of letters with results ** retrieved from db in this format ** Array (4) ** 0=> A ** 1=> L ** 2=> M ** 3=> O */ $smarty->assign('broker_coverages_letters',$broker_coverages_letters); ===[ in_array function ]============= /* check that needle / haystack are set */ $in_array = in_array ($params['needle'], $params['haystack']); if (!empty($params['assign'])) { $smarty->assign($params['assign'],$in_array); } ===[ end in_array function ]========= ===[ alphamenu template ]============ {section name=letter loop=$abc} {in_array assign=linkit needle=$abc[letter] haystack=$broker_coverages_letters} {if $linkit} <a href="coverages.pgp?mode=alpha&letter={$abc[letter]}">{$abc[letter]}</a> {else} {$abc[letter]} {/if} {if !$smarty.section.letter.last} | {/if} {/section} ===[ end alphamenu template ]======== Thanks, olinux __________________________________________________ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, forms, and more http://tax.yahoo.com

« previous php.smarty.general (#9212) next »