Re: in_array()
| From: | Roel Vanhout | Date: | Sun, 24 Jun 2001 20:33:59 +0000 |
| Subject: | Re: in_array() | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-972@lists.php.net to get a copy of this message | ||
On Sun, Jun 24, 2001 at 08:50:58PM +0200, hans@linux.gelrevision.nl wrote:
> On 24-Jun-01 Roel Vanhout wrote:
> > On Sun, Jun 24, 2001 at 07:24:46PM +0200, hans@linux.gelrevision.nl wrote:
> >> needed) to a string. Since I don't like to store pure html within my php I
> >> would like to know if there is any in_array() function within smarty that I
> >> didn't discover.
> > Use html_options. It can handle multiple selections by passing an array
> > into 'selected'.
> I've tried to use it. Don't seem to succeed since $customer_id (from the
> example) would be an array in my problem. I will try it again later but for now
> I will fix it with some html in my php code.
Yes, if you pass an array into $customer_id, it will work. Look at
smarty_func_html_options() in Smarty.addons.php:
if (in_array($sel_check, $selected))
$html_result .= " selected";
Even if you only pass in one element to be selected, this element will
be casted to an array and in_array() will be used on it.
cheers,
roel
--
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
[...]
#define EMACS 666 /* Editor Too Large */