Re: [SMARTY] count element of array ?
| From: | Mark Gibson | Date: | Thu, 08 Apr 2004 13:49:49 +0000 |
| Subject: | Re: [SMARTY] count element of array ? | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-11250@lists.php.net to get a copy of this message | ||
Mark Gibson wrote:
adwinwijaya wrote:Actually, i've just discovered that you can use any PHP function as a modifier! So to join all elements of an array, the following should work: {$array|@implode:','} (NOTE: the @ indicates that the modifier should be applied to the array as a whole, otherwise it is applied to every element) And to count elements in an array: {$array|@count} So, to assign the array count to variable: {assign var='mycount' value=$array|@count} then the count can be obtained with: {$mycount} -- Mark Gibson <gibsonm |AT| cromwell |DOT| co |DOT| uk> Web Developer & Database Admin Cromwell Tools Ltd. Leicester, England.I need that to formating the string ... for example I have an array contain {'a','b','c','d'} and I want to print it as a,b,c,d (with ',') but after d .. it doesnt need to add ',' ..Try this plugin: [snip]